Joomla 3 template: php check category and show html - joomla

Joomla 3.2.1
I have a category with 26 subcategories.
In my template I want to add some code that shows 2 modules if the page is from one of the 27 categories.
I tried this code
<?php if (JRequest::getVar('view')=='categories' && JRequest::getVar('id')==30) { ?>
<div id="menu_abc">
<jdoc:include type="modules" name="menu_abc" />
</div><!-- end menu_abc -->
<?php } ?>
But that's only one category and it didn't work. The modules didn't show in that one category page (a category list page and an article in one of the subcategories).
I want the modules to show automatic only on all article pages, category list pages en category blog pages of this 27 categories.
Does someone know how to do this? It's only a small piece of code so I prefer not to use another template and cameleon or something if that's possible.

Related

Infinite Scroll On Custom Page Magento

I have installed Strategery InfiniteScroll. Which is working great for category listing page. Now i have a custom product page. I want to apply Strategery InfiniteScroll on my custom product page. How to do.?
My Page
<?php
$_productCollection=$this->getLoadedProductCollection();
$_productCollection = Mage::getResourceModel('catalog/product_collection')
->addAttributeToSelect('*')
->addFieldToFilter(array(array('attribute'=>'featured','eq'=>'1')));
$_productCollection->getSelect()->order('rand()');
$_productCollection->getSelect()->limit(20);
?>
//loop for products
</div>
</div>
Before you start, assure you have included .js file in your custom page.
if you see the ias.phtml template, it has some container defined.
You need to add the same code for your custom page.
For documentation of infinite ajax scroll, read this

How to remove data from header menu and add new content to it in Magento

I am working with magento.
I have been trying to remove the content from header-menu and add fresh content like
**HOME ABOUTUS SITES CONTACT**
Here is the current situation,
Update
Above is the screen shot that follows after the top-menu
Please guide me to achieve this..
Thank you.
I assume the above menutimes that you've shown in the image are categories. So if you don't need it on the top menu then go to each of the categories (under Catalog -> Manage Categories) in the backend / admin panel and choose "NO" as an value to the option "Include in Navigation Menu". This will remove them from the navigation top menu.
And to bring these menu items
HOME ABOUTUS SITES
Let me describe it for one of the items above. Lets take About Us
At first create the respective CMS static block for "About Us"
Create a category called "About Us"
Go to display settings of the About Us category and choose the display mode as "static block only" and then select the static block "about us"
Save the category and reload your page on the frontend/website
you can find the "about us" category on the top menu and opening it will show the content from the static block.
Repeat the same for the other menu items.
If this helps mark it as answer. Thanks.
I think you didn't want categories in top menu. In place of it you want Custom links like "Home", "About us" etc.
For this open topmenu.phtml file in template->page->html.
In this commented the below line :-
<?php echo $_menu ?>
and in place of it call a static block of name "custom_top_nav" :-
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId('custom_top_nav')->toHtml() ?>
In this block you can make your custom menu.
We you want both custom links plus categories then you can replace code with this:-
<?php $_menu = $this->getHtml('level-top') ?>
<?php if($_menu): ?>
<div class="nav-container">
<ul id="nav">
<li class="home"> HOME </li>
<?php echo $_menu ?>
</ul>
</div>
<?php endif ?>
Magento hide categories in the header menu - This can be done from your Admin Panel under Manage Categories > To do this is easy if you don't want your categories in top menu of your web site - When you add a new Category Select no for > Include in Navigation Menu * Its under Meta Description at the bottom of the page where you add the the Category name in General Information Tab*

Joomla Change Modules in Sidebar on diffrent Pages

I'm using Joomla 2.5.7 and want to ask, how I can change a bunch of modules in sidebar, when I change to another Page. An example to clarify my question:
I have 3 Links at the navigation bar:
Events
Shop
Blog
and a Homepage as index.html (logical).
Now, I want display in Events the modules "Where to go" and "About Location" in the sidebar.
In Shop I want to display the modules "About Dealer", "Shipping" and "Images" in the sidebar without the modules "Where to go" and "About location".
In Blog I want to display the module "About Author" in sidebar without the modules above (Where to go, about location...).
So, I know I can do this (or similar):
<?php if ($this->countModules('sidebar-a and sidebar-b and sidebar-c')): ?>
<jdoc:include type="modules" name="sidebar-a" />
<jdoc:include type="modules" name="sidebar-b" />
<jdoc:include type="modules" name="sidebar-c" />
<?php endif; ?>
SIDEBAR-A: "Where to go" and "About Location"
SIDEBAR-B: "About Dealer", "Shipping" and "Images"
SIDEBAR-C: "About Author"
But that is not my plan!
I want just the position "sidebar-a" and that the modules getting hidden (like in countModules) if they are not for this page.
I see this method on the granty framework:
<?php /** Begin Main Body **/ ?>
<?php echo $gantry->displayMainbody
'mainbody','sidebar','standard','standard','standard','standard','standard'); ?>
<?php /** End Main Body **/ ?>
You see just simple code, but with other variables.
So very easy in the index.html but this won't work If I do copy and paste ;)(logical)
I don't know how to do it. I do not prefer to get this framework, just for this single sidebar. But there must be a way like this granty framework, but I can't understand the code very well...I'm just an amateur on php. I guess there must be a JavaScript file, which hide and display this diffrent modules.
You can see a live demo here of the single sidebar with lots of modules, which getting hidden and displayed on each page: http://app.ohanah.com/demo-v2/rt/index.php
Have someone an idea how to run this sidebar?
Thanks for reading and helping!
In the Joomla backend, go to the Module Manager, open the module you want to change, and in the bottom left, you can assign the module to specific pages. This should be what you're looking for and it will save you having to hard code it.
You can , for better handling, use the Module Everywhere extension , look for it in JED.
It helps you a lot assigning modules not only to menulinks, but even to articles.

Joomla show subcategory image on category page?

Is there a way, beside creating yet another MYSQL connection, to retrieve subcategory image while browsing parent category page?
For example:
Main category (set as category as blog)
Subcategory 1 (image set in Basic options image field)
Subcategory 2 (image set in Basic options image field)
Subcategory 3 (image set in Basic options image field)
....
Now, when i browse 'Main category', it display categories title and description of subcategories, but I cant find any 'normal' way to retrieve image that i set in basic option.
The only way that I can make to work is to create another MYSQL call and retrieve image from database, but I would like to know if there is another more effective way.
Im using Joomla 2.5.
Thanks!
I suggest you override the output of the content so that you can add some code to output your images.
Copy:
joomla/components/com_content/views/category/tmpl/blog_children.php
To:
joomla/templates/yourtemplate/html/com_content/category/blog_children.php
Then edit your new override file, just below:
<span class="item-title"><a href="<?php echo JRoute::_(ContentHelperRoute::getCategoryRoute($child->id));?>">
<?php echo $this->escape($child->title); ?></a>
</span>
Add:
<div class="item-image">
<?php echo '<img src="'.json_decode($child->params)->image . '" />'; ?>
</div>
See Joomla docs for Component Output Types and Layout Overrides.

Magento - Display Individual Products

Is there an easy way in Magento to display individual products in a cms page without copying and pasting the code from the catalog pages?
I have a blog on my magento store and sometimes I'd like to drop the listing for individual products into the posts.
A code block in Magento is the best way to achieve this effect. If you look at your home page, that's how new products are generated dynamically:
{{block type="catalog/product_new" template="catalog/product/new.phtml"}}
If you created another block for a 'featured' item that took a product ID as a parameter, you could place that block on the static page and it would show that item. This page shows a brief example, but for the sake of being complete, I'll reproduce it here:
First create a new .phtml file with the following undercatalog/product/view/your_new_page.phtml
<?php
$productId = $this->getProduct_id();
$_product = Mage::getModel('catalog/product')->load($productId); //load the product
?>
<img src="<? echo Mage::helper('catalog/image')->init($_product, 'thumbnail')>resize(75, 75); ?>" alt="<?php echo $this->htmlEscape($_product['name']); ?>" border="0" width="75" />
Now simply add the following to your CMS Page or Block and adjust the product ID to the product Image you wish to view:
{{block type="catalog/product_new" product_id="1" template="catalog/product/view/your_new_page.phtml"}}
I'd probably tweak it a bit for readability if I used this on my store, but I'm also a bit overzealous in terms of using human-readable code. :)
If you are working on Magento 1.4, you should take a look at widgets which do exactly what you want.

Resources