After upgrading to 1.9.0.1 we had a problem with javascript scripts not refreshing after AJAX updates.The official support time is 6 months but even 1 ... Read more

Apr 14, 2015 Poleposition

Certified Magento Enterprise developer Certified Magento developer Certified Magento theme developer Certified Magento specialist

Manadev is certified extension and theme
developer for Magento

Method Reference

Contents:

category()

On category page, returns ID of currently displayed category. On other pages, returns null.

Example:

if ($this->category()) {
    // we are on category page
}

if ($this->category() == 18) {
    // we are on category page and ID of currently displayed category is 18
}

cms()

On CMS page which is not a home page, returns ID of currently displayed CMS page. On other pages, returns null.

Example:

if ($this->cms()) {
    // we are on CMS page
}

if ($this->cms() == 18) {
    // we are on CMS page and ID of currently displayed CMS page is 18
}

filter($name)

Parameters:

  • $name - internal name of the filter. For attribute-based filters it is attribute code.

Returns helper object for operating on all applied items of specified filter.

See subsections for available helper object methods and examples.

contains($value)

Parameters:

  • $value - item label as shown in "Currently applied filters" section in frontend.

Returns true if in specified item label is present in list of currenty applied filters and false otherwise.

Example:

if ($this->filter('activity')->contains('Gym')) {
    // there is "activity=Gym" in list of currently applied filters
}

count()

Returns number of items of specified filter which are present in current applied filters list.

Example:

if ($this->filter('activity')->count() > 1) {
    // there is more than 1 "activity" filter in list of currently applied filters
}

first()

Returns first item label of specified filter from list of currently applied filters or null if there is no such item.

Example:

echo $this->filter('activity')->first();

exclude($value = null)

Parameters:

  • $value - (optional) item label to be excluded. If this parameter is omitted, then all items of specified filter are excluded.

Marks specified filter item as "excluded". Excluded filter items are omitted by $this->filters()->allIncluded() and $this->filters()->countIncluded() methods.

Also see Excluded filters.

Example:

// the following line marks all applied items of `activity` filter as excluded
$this->filter('activity')->exclude();

// the following line marks only "activity=Gym" applied item as excluded
$this->filter('activity')->exclude('Gym');

filters()

Returns helper object for operating on list of all currently applied filter items.

See subsections for available helper object methods and examples.

all()

Returns array of all currently applied filters. Each element is of FilterData type.

Example:

<ul>
    <?php foreach ($this->filters()->all() as $filter): ?>
        <li><?php echo $filter->item_label ?></li>            
    <?php endforeach; ?>
</ul>

allIncluded()

Returns array of all currently applied filters which are not excluded. Each element is of FilterData type.

Also see Excluded filters.

Example:

<ul>
    <?php foreach ($this->filters()->allIncluded() as $filter): ?>
        <li><?php echo $filter->item_label ?></li>            
    <?php endforeach; ?>
</ul>

are($filters)

Parameters:

  • $filters - array denoting filter combination being checked. In this array, keys mean internal filter names (attribute codes) and values are item labels.

Returns true if currently applied filters are exactly the same as specified, and false otherwise.

Example:

if ($this->filters()->are(['color' => 'Red', 'style_general' => 'Insulated'])) {
    // this branch is executed if and only if 2 filters are applied: 
    //      color=Red and style_general=Insulated
}

count($filterName = null)

Parameters:

  • $filterName - (optional). If specified, only applied filter items of this filter are counted. If omitted, all applied filters are counted.

Returns number of currently applied filters.

Example:

echo $this->filters()->count() . ' filters applied';

countIncluded($filterName = null)

Parameters:

  • $filterName - (optional). If specified, only applied filter items of this filter are counted. If omitted, all applied filters are counted.

Also see Excluded filters.

Returns number of currently applied filters which are not marked as excluded.

Example:

echo $this->filters()->countIncluded() . ' filters applied';

home()

Returns true if user is currently on home page and false otherwise.

originalDescription()

Returns original page description:

  • category description on category pages
  • CMS page content on CMS pages

Can only be called from description.phtml template.

Example:

<?php echo $this->originalDescription() ?>

originalFollow()

Returns FOLLOW or NOFOLLOW string calculated according to SEO Layered Navigation Plus settings.

Can only be called from meta_follow.phtml template.

Example:

echo $this->originalFollow();

originalH1Title()

Returns original page title:

  • category name on category pages
  • CMS page heading on CMS pages
  • search keyword on quick search page

Can only be called from h1_title.phtml template.

Example:

<?php echo $this->originalH1Title() ?>

originalIndex()

Returns INDEX or NOINDEX string calculated according to SEO Layered Navigation Plus settings.

Can only be called from meta_index.phtml template.

Example:

echo $this->originalIndex();

originalMetaDescription()

Returns original page meta description.

Can only be called from meta_description.phtml template.

Example:

echo $this->originalMetaDescription();

originalMetaKeywords()

Returns original page meta keywords (string).

Can only be called from meta_keywords.phtml template.

Example:

echo $this->originalMetaKeywords();

originalMetaTitle()

Returns original page meta title.

Can only be called from meta_title.phtml template.

Example:

echo $this->originalMetaTitle();

page()

Returns current product list toolbar page number.

if ($this->page() > 1) {
    echo __(" (Page %d)", $this->page());
}

Returns search term string on quick search page and null on other pages.

if ($this->search()) {
    // we are on quick search page
}

if (mb_strtolower($this->category()) == 'jackets') {
    // we are on quick search page and search term is "jackets"
}

We Accept: PayPal Visa MasterCard American Express Discover