how do i link to a specfic block in a page? - magento

I had displayed part of "latest testimonial" (textarea) on my home page, and placed a "view more" link in the end.
Now I want to link to that specific testimonial on a page when "view more" is clicked.
But I had a list of testimonials on a single testimonial page, meaning no separate detail page for each testimonial. So how can I display the specific testimonial on the page ?
<?php echo $this->getUrl('testimonial'); ?>
this gives a link to my testimonial page.

First you need to provide some element IDs on your testimonials page. For example if each testimonial is in a quote:
<blockquote id="testimonial001">
...
</blockquote>
Or place a named anchor just before each testimonial:
<a id="testimonial001"></a>
...
Then your URL can be built with a fragment:
<?php echo $this->getUrl('testimonial', array('_fragment'=>'testimonial001')); ?>
By specifying the ID through a route parameter you will override any other fragment that might get set by another module (don't know which, just know that it can happen) which is preferable to merely appending it.

example below should generate a link this this: http://www.example.com/testimonial#anchor
<?php echo getUrl('testimonial'); ?>#anchor
The rest you can find in this document: http://www.w3schools.com/tags/tag_a.asp
using this example: http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_link_bookmark

Related

Remove Trailing Slash from Magento URL

I understand there are many answered questions on this particular issue but I haven't found anything specific to Magento, and I was wondering if changing the .htaccess file will have repercussions in my Magento store.
Basically I have links in my navigation that go straight to a filtered category page so they look as follows..
Example.com/hairproducts.html?manufacturer=412
However when I click these links they end up navigating to the URL with a trailing slash...
Example.com/hairproducts.html?manufacturer=412/
which then ignores the filter and takes them to the category page.
Cheers for any help.
I assume you have the urls generated in a phtml file like this:
<?php echo $this->getUrl('hairproducts.html?manufacturer=412'); ?>
or in a block/page content like this
{{store url="hairproducts.html?manufacturer=412"}}
Change them to this:
In a phtml file:
<?php echo $this->getUrl('', array('_direct'=>'hairproducts.html', '_query'=>'manufacturer=412'); ?>
or in a block/page content
{{store _direct="hairproducts.html" _query="manufacturer=412"}}
If I assumed wrong then post the way you are generating the urls.

display module only on the front page of virtuemart joomla 2.5

hi i want to display module only on the front page of virtuemart and dont want that module on inner pages. i have search about this, but did not get anything.
I tried to used this code but it does not effect.
<?php if (JRequest::getVar('view')=='productdetails') { ?>
<div id="productmod"><jdoc:include type="modules" name="productdetails" /></div>
<?php } ?>
Can anyone help me to figureout this problem
Thanks In advance..
take a look on the answer, and var_dump the $menuList to get all the menus, then just get the specific menu and apply your condition..
// Get default menu - JMenu object, look at JMenu api docs
$menu = JFactory::getApplication()->getMenu();
// Get menu items - array with menu items
$menuList = $menu->getMenu();
// Look through the menu structure, once you understand it
// do a loop and find the link that you need.
var_dump($menuList);
take a look on the give link how to determine the front or default page

create link in Joomla

Hi everyone I have a component in joomla 2.5 that show a list of element.
Now I want to view a particular item, how to create a link to past the id of this element and see the whole description
I have this
<a href="<?php echo JRoute::_('index.php?option=com_productos&view=especialidad8780&Itemid=1'); ?>" >este</>
but dont show me the Itemid=1
the browser take this router
index.php?option=com_productos&view=especialidad8780&lang=es
this the correct form to do a link in joomla?
thanks
David is right. The "itemId" is a reserved variable for menu item (to set the 'active' class on a clicked menu element). Try to switch to id, productid, ...
And you also have a little mistake in your link (closure a was missing):
<a href="<?php echo JRoute::_('index.php?option=com_productos&view=especialidad8780&Itemid=1'); ?>" >este</a>
If you are trying to link to a particular item, you commonly use &id=1. Itemid is reserved for linking to menu items and would be added automatically as necessary by the JRoute call.

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.

How to retrieve Categories name and children ? Magento

I would like to retrieve the categories of my website in order to build me own Category menu.
but I don't understand how to get all the categories from the class/model. So I've created a file called top.phtml that I've put in template/catalog/navigation ,
First, do I MUST put that name to the file into that folder if I want to create a top Menu ? Can t I decide where to put it with the name I want like TopMenu.phtml ? Because in evry tut I red, they are doing the same way ..
Second : What i the function I must call ? I've been here : http://www.magentix.fr/ergonomie-web/agencer-page-accueil-site-magento.html but the way the do that doesn t work for me .. I add that code to my file top.phtml properly called in the page.xml :
<div class="category-list" style="background-color:white;">
<h2>Nos produits</h2>
<?php
foreach ($this->getStoreCategories() as $_category):
if($_category->getIsActive()):
$_category = Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer')->setCurrentCategory($_category);
?>
<div class="category-list-view">
<a href="<?php echo $this->getCategoryUrl($_category)?>" title="<?php echo $_category->getName()?>">
<img src="<?php echo $this->getCurrentCategory()->getImageUrl(); ?>" alt="<?php echo $_category->getName() ?>" />
</a>
<h3><?php echo $_category->getName()?></h3>
</div>
<?php
endif;
endforeach;
?>
</div>
Last : where could I find a clear user guide like there is for CodeIgniter ? I found that, but I never found any answer on it : http://www.magentocommerce.com/wiki/doc/webservices-api/api#magento_core_api
Thanks for your answers, I m a web dev used to work with CodeIgniter or without any template, and I can t clearly see the logic behind Magento way of programming.
EDIT: Is there anything to do with the categories ? Becaue I tried to create a sub category under the Default Category and it do work, but if I create a new Root Category,It simply didnt recognize it .. why
First, do I MUST put that name to the file into that folder if I want to create a top Menu ? Can t I decide where to put it with the name I want like TopMenu.phtml ? Because in evry tut I red, they are doing the same way ..
You can name your template file whatever you like. However, it's best to follow the nomenclature and established conventions. The template filename is contingent on your layout XML. It should have the template attribute, something like <block name="x" type="x/y" template="catalog/navigation/topmenu.phtml" /> (for example).
Second : What i the function I must call ? I've been here : http://www.magentix.fr/ergonomie-web/agencer-page-accueil-site-magento.html but the way the do that doesn t work for me
The functions available to your template (topmenu.phtml file) depend on the block's type. In your layout XML, you should specify the block type that corresponds to the functionality you need. In your case, you're probably looking for the block type to be catalog/navigation. If you look in ./app/code/core/Mage/Catalog/Block/Navigation.php, you can see what public methods are available to your template. Several of the methods here facilitate generating (nested) category listing. This is where your getStoreCategories() method comes from. Remember that these blocks inherit from several parenting classes, so you have a lot more methods available than you may at first think.
where could I find a clear user guide like there is for CodeIgniter ? I found that, but I never found any answer on it : http://www.magentocommerce.com/wiki/doc/webservices-api/api#magento_core_api
That's a link to the Magento API. What you need is a tutorial on Magento layout XML and the design layer therein. The Magento wiki has some good info, but Google around and you'll find a ton of really helpful resources on understanding Magento's design system.
Is there anything to do with the categories ? Becaue I tried to create a sub category under the Default Category and it do work, but if I create a new Root Category,It simply didnt recognize it .. why
A root category is what you'll use to identify the basis of the catalog for the selected store(s). You will never see the root category appear on the frontend (and you shouldn't). Each subcategory within the root category is the top-level category; sub-categories beneath those subcategories (tertiary categories) would appear as your "second-level" categories on the Magento frontend. You might want to look into Magento's GWS ("global, website, store") scope system, and how it manages catalog data in a multi-store setup to better understand why root categories function this way.
Hope this helps!

Resources