Joomla k2 - Removing Item Title from Breadcrumbs - joomla

How should I remove item titles from k2 breadcrumbs and only have category names displayed?
For example:
Home> Category1 > Category2 > Item Title
be turned to:
Home> Category1 > Category2

I share the answer that I found a few month ago:
In the path /modules/mod_k2_tools/helper.php, the line $title = $row->title; should be changed to $title = "";
And also, there are some good extensions to manipulate breadcrumbs.

Related

Using Magento API to add all products to root category

I want to set all the products to the root category (next to the current category they are in).
I know the best way to do this is using the Magento API, but can somebody get me started on this?
Just to be clear, i don't want to change the category id, i just want to add another category id to the product.
EDIT
It takes a lot time to check all 3000+ products to see in what other category it is. Example: Root_catId = 175 Product_1 cat = 3 (needs to be: 3, 175) Product_2 cat = 9 (needs to be: 9, 175)
You can do this without using the API but if you want to use the API try following.
You can use following first you need to create a user with permissions to access soap requests in Magento admin
<?php
$proxy = new SoapClient('http://yourmagento/api/v2_soap/?wsdl');
$sessionId = $proxy->login('apiUser', 'apiKey');
$result = $proxy->catalogCategoryAssignProduct($sessionId, '3', '10'); // 3 is category id and 10 is product id
You can loop through every product to assign the product to a specific category.
Replace the root category id with the category id which you require.

Select siblings of blockcategories (Prestashop, Smarty)

We have a blockcategories menu in Prestashop with about 400 categories total including all the subcategories, and this is creating too many links on each of our page, resulting in not-optimal onpage SEO.
I want to add rel="nofollow" and some Javascript to all links except the root and the selected category and it's children and siblings.
Example:
- Subcategory A (Root, dofollow)
- Subcategory A-1(Sibling of selected, dofollow)
- Subcategory A-2 (Selected, dofollow)
- Subcategory A-2-a (Child of selected, dofollow)
- Subcategory A-2-b (Child of selected, dofollow)
- Subcategory A-2-c (Child of selected, dofollow)
- Subcategory A-3 (Sibling of selected, dofollow)
- Subcategory B (Root, dofollow)
- Subcategory B-1 (Nofollow)
- Subcategory B-2 (Nofollow)
- Subcategory B-2-a (Nofollow)
- Subcategory B-2-b (Nofollow)
- Subcategory B-3 (Nofollow)
- Subcategory C (Root, dofollow)
- Subcategory D (Root, dofollow)
I have been successful with Selecting the Root, the Selected and the Children of the selected. However I've been unsuccessful with selecting the Siblings of the selected (That share the same Parent).
How do I Select the Siblings of the Selected Category within the Blockcategories .tpl files?
PrestaShop is using a nested set model to store its categories:
http://www.fliquidstudios.com/2008/12/23/nested-set-in-mysql/
http://en.wikipedia.org/wiki/Nested_set_model
This allows you to easily select a part of the tree (parents, children, siblings, etc.).
Each "Category" object has a nleft and nright member that will help you to perform these selections.
Another easier way is to use the level_depth member, all siblings will have an identical level_depth value.
You can modify the blockcategories.php file to add level_depth in the SELECT statement of hookLeftColumn(). Then in the category-tree-branch.tpl file, simple add a test:
{if $node.level_depth == ....}rel="nofollow"{/if}
Be careful, Google might not like the fact that one some pages a category is nofollow and dofollow on other pages.
i've had very similar problem - i needed to change style of all siblings of the selected category so the solution is the same
you need to modify category-tree-branch.tpl
<li {if isset($last) && $last == 'true'}class="last"{/if}>
{assign var="RET" value=""}
{if $node.children|#count > 0}
{foreach from=$node.children item=child name=categoryTreeBranch}
{if $smarty.foreach.categoryTreeBranch.last}
{include file="$branche_tpl_path" node=$child last='true' assign='childItems'}
{else}
{include file="$branche_tpl_path" node=$child last='false' assign='childItems'}
{/if}
{assign var="RET" value="{$RET}{$childItems}"}
{/foreach}
{/if}
<a href="{$node.link|escape:'htmlall':'UTF-8'}" {if $RET|strpos:'selected'} class="parentselect"{/if}{if isset($currentCategoryId) && $node.id == $currentCategoryId}class="selected"{/if}
title="{$node.desc|strip_tags|trim|escape:'htmlall':'UTF-8'}">{$node.name|escape:'htmlall':'UTF-8'}</a>
{if $RET}<ul>{$RET}</ul>{/if}
</li>
all you need is to put whatever you need between {if $RET|strpos:'selected'} and {\if} for active branch ...or change the condition for non-selected branch {if $RET|strpos:'selected'==false}
I solved this by modifying blockcategories.php, blockcategories.tpl and category-tree-branch.tpl.
First in blockcategories.php I edited rows 148 and 246.
Row 148 is the getTree() where the module assign the return array called $node in the .tpl files. Here I add the following line to the array (I assign parent the id_parent value:
'parent' => $resultIds[$id_category]['id_parent']
At row 246 I add "currentCategoryParent" to the smarty->assign array.
$this->smarty->assign(array('currentCategory' => $category, 'currentCategoryId' => $category->id, 'currentCategoryParent' => $category->id_parent));
I can then access these variables from the .tpl files using $currentCategoryParent and $node.parent.

Magento set "Show All" products by specific category (or in .phtml) rather than globally

I'm aware of the setting in the admin panel for the default number of products to show on the category list pages. This appears to be a global setting for the whole store. I'm looking for a way to set this on a per category basis (e.g. have most categories default to 25 products per page, but one specific category default to showing all products on the first page). Ideally this would be done in admin or in a .phtml file if possible. How can I set the default products per page for a specific category?
Take a look in
design/package/theme/catalog/product/list/toolbar.phtml
The items per page select drop down is generated by a for loop around:
$this->getAvailableLimit()
The block for the toolbar has the following method on it:
public function getLimitUrl($limit)
{
return $this->getPagerUrl(array(
$this->getLimitVarName() => $limit,
$this->getPageVarName() => null
));
}
The trick is to do one of the two following:
1) leverage magento to build the proper url when it is injected in any link directing to the category you want to be in view all mode.
2) on the /catalog/product/list/toolbar.phtml block check the current category, if the current category is the desired category execute the following code:
if( strtoupper($this->getLimitVarName()) != "ALL" )
{
$viewAllUrl = $this->getLimitUrl('All');
$this->_redirectUrl( $viewAllUrl );
}
At Admin Panel
Go to -> CMS -> Pages -> Home Page
Click on "Content" tab on LEFT
Click on "Show/Hide Editor" Button at RIGHT
Copy - Paste This Code there :
{{block type="catalog/product_list" category_id="2" template="catalog/product/list.phtml"}}
Give Category ID of your desired Category
To check Category_id of any category Go to : Catalog Menu -> Manage Catagories
Click on category, at right side's TITLE somewhat like will be displayed :
"CATEGORY_NAME ( ID : 5 )"
Regards.

Count articles in category

I would like to display article count in a single category.
$categoryName = "CategoryName";
$n = count($this->category->$categoryName);
echo "This category has ".$n." articles in it!";
This is not working (example).
There is a parameter allowing you to do this already. Assign a Category List or Category Blog Menu item and then choose under the Category Options parameters tab. Change No Articles Message to show.
The reason that your code isn't working - is because a single category is just represented by $this->category.
However for either Category Blog or Category List layouts you can simply use:
$categoryName = "CategoryName";
if($this->category->title==$categoryName) {
count($this->category->getNumItems(true))
}
http://docs.joomla.org/Help25:Menus_Menu_Item_Article_Category_Blog#Category_Options
Try this.
The default category layout contain the count of the articles in it.
take a look at this components\com_content\views\categories\tmpl
Also you can found the count count($item->getChildren())
Hope this may you..

Magento - show the stock indicator on product list

how can I show the stock indicator on Magento product list ?
Thanks a lot.
To show the quantity of items left in stock use this:
<?php echo (int) Mage::getModel('cataloginventory/stock_item')->loadByProduct($_product)->getQty(); ?>

Resources