How to show metamod module only on k2 article view - joomla

How to show metamod module only on k2 article view and not category view ?
please help

See this note about loadmodule feature in Joomla/K2 Articles if you need the module only for some articles:
http://docs.joomla.org/How_do_you_put_a_module_inside_an_article
If you need it for all K2 articles you may need to load conditionally a specific position from your template in this way:
<?php if ($this->countModules( 'your_mod_position' ) && $option=='com_k2' && $view=='item') : ?>
<jdoc:include type="modules" name="your_mod_position" />
<?php endif; ?>

Related

Magento: Switch From Grid view To List View, Without Changing URL

I was wondering if you could guide me how to allow the user to select either list or grid view, without changing the URL of the catalog/category page.
I.e., the page is either www.example.com/category?mode=grid OR www.example.com/category?mode=list but I want to make it just www.example.com/category and show the grid view by default, with the list view being displayed without changing the URL.
I hope you can help
There is no tutorial I guess..you have to do your own code ..And its not a big deal .. Open your list.phtml file in app/design/frontend/default/YOURTHEME/template/catalog/product/
Here you can see, they separate two view mode like this,
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
..bla.. bla ...
And Grid mode:
<?php else: ?>
<?php // Grid Mode ?>
Here they check the mode like this
<?php if($this->getMode()!='grid'): ?>
Just remove this condition, so that you can load both views, so now just add new css class or id to separate both modes, and manage them by Js like onclik event or something like that ...

Show Product on Search Page - Magento 1.7

Currently I have a snippet of code that will forward a user to the product page if they search for a term and only 1 product is associated with that keyword.
<?php if($this->getResultCount() == 1): ?>
<?php $prodId = $this->_productCollection->getAllIds() ?>
<?php $singleProduct = Mage::getModel('catalog/product')->load($prodId) ?>
<?php header('Location: ' . $singleProduct->getProductUrl()) ?>
<?php exit; ?>
<?php elseif($this->getResultCount()): ?>
However, what I want to do now is actually serve up the product and all its details on the results page itself if its the only one with that tag/search term INSTEAD of redirecting to the product page. Im pretty new to php so please bear with me.
Block template is bad place for this. Good place - controller.
Maybe you need rewrite controller for this functionality.
For example/app/code/core/Mage/CatalogSearch/controllers/ResultController.php
In controller your code looks like:
$this->getResponse()->setRedirect($_product->getProductUrl());

Is it possible to target just Simple Product from phtml template?

I see something like:
<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
and this
<?php if(!$_product->isGrouped()): ?>
But couldn't find a way to target only the Simple Product type in similar manner.
<?php if( $_product->getTypeId() == 'simple' ): ?>
As an alternative possibility you could assume a Simple product is on that is no other type.
<?php if (!$_item->isComposite() && !$_item->isSuper() && !$_item->isVirtual()): ?>
<!-- Simple type only -->
<?php endif; ?>
There is already a template file catalog/product/view/type/simple.phtml that only displays for Simple type products.
If that doesn't show in the right place for you look in layout/catalog.xml for <PRODUCT_TYPE_simple> to see how to make your own Simple-only template file.

Adding <jdoc:include calls in Component Templates

I'm integrating a component template for a customer. He is using custom templates for com_user / login & reset views.
His site is also using a lot of modules. How can I activate these modules for the component in total, instead of a menu item?
In the module template (user/login/tmpl/default.php) I wrote: <jdoc:include type="modules" name="ja-news" />, which doesn't work.
Thanks for any answers!
BR,
Sebastian
Found the solution in http://forum.joomla.org/viewtopic.php?f=231&t=247191
<?php
$zone = "ja-news";
$modules =& JModuleHelper::getModules($zone);
foreach ($modules as $module){
echo JModuleHelper::renderModule($module);
}
?>
I guess it would be good to have <jdoc:include with an additional force="true" parameter..

Get Current Top Level Category with Magento

How do I get the current (active) top level category and its subcategories??
I do not want the root category, just the highest level category and all of its subcategories.
If I am in the Women’s Category for instance:
Women
- Apparel
-- Shirts
-- Pants
- Accessories
-- Handbags
-- Jewelry
Even if i am looking at shirts, i would like the category tree to remain the same.
Any help would be greatly appreciated.
To give the precise answer to your precise question "how to get the current category and its subcategories" :
To retrieve the current category :
$_currentCategory = $this->getCurrentCategory();
To retrieve its subcategories :
$_categories = $this->getCurrentChildCategories();
The above are working in a catalog/navigation block.
Now, to get the rendering you are speaking about, I think that a simple navigation block with a good use of CSS would do the trick.
Create a navigation block, let's say in your left column :
Create the template file in your template directory structure. In our example :
/template/catalog/navigation/thetemplate.phtml
Use this code to draw the whole categories/subcategories structure without the hassle of modifying the code (see [1] at the end of the post....)
Inspect the generated code/CSS and you will see that there are all necessary CSS pointers (levelX, active...) allowing you to display or hide pieces of the categories tree and thus showing only the parts you like.
Conclusion: CSS is sufficient to do what you want to do :)
[1] Code :
<?php $_menu = ''?>
<?php foreach ($this->getStoreCategories() as $_category): ?>
<?php $_menu .= $this->drawItem($_category) ?>
<?php endforeach ?>
<?php if ($_menu): ?>
<div class="THECSS-CONTAINER">
<ul id="THECSS">
<?php echo $_menu; ?>
</ul>
</div>
<?php endif; ?>

Resources