I have attached joomla's Menu module in my template. But I needed it to load in footer position at the same time. So that if I add another menu it should be get added in both the positions in Header and in the footer... What i want to do to load a menu module to two different positions in a page, in header and in footer.
I had tried to add multiple positions in administrator section for a menu module...
screen shots are as follows
For latest version. Joomla3.x :
Get all the modules by template position(replace position with your template position):
<?php
$modules = JModuleHelper::getModules("position");
$document = JFactory::getDocument();
$attribs = array();
$attribs['style'] = 'xhtml';
foreach ($modules as $mod) {
echo JModuleHelper::renderModule($mod, $attribs);
}
?>
Other Solution: you can define position in the template and assign module to that position
Steps:
1.Customize templateDetails.xml file
add
newposition
2.create position in index file of template
in templates/your_template/index.php
<jdoc:include type="modules" name="newposition" />
If I understand correctly, you should simply be able to duplicate your menu module (in extensions->modules) and add the duplicate module to a module position in the footer of your template. If there is no module position in the footer, you add one to the - list in templateDetails.xml, and add it to index.php in your template, like:
<jdoc:include type="modules" name="footer-menu" style="xhtml" />
Related
How to do in joomla:
<jdoc:include type="component" />
using php. I want to get page body by for example menu id, or menu link.
I know that for module I can use:
$module = &JModuleHelper::getModule('mod_module');
$result = JModuleHelper::renderModule($module);
But what about content
I am trying to add a custom style to each list item within Joomla!s Category List output which gives me the following html
<div class="blog">
<div class="cat-children">
<ul>
<li class="first">
<span class="item-title">HYT
</span>
</li>
<li></li>
</ul>
</div>
</div>
I think what I need to do is add something like:
<li id="myID<?php echo $this->item->catid; ?> ">
The trouble is I can't find which file to override. I have looked in /templates/mytemplate/html/com_content/category/ as well as /components/com_content/views/category/tmpl yet none of the files seem to have a an unordered list within them that relates to cat-chidren.
So my first question is which file should I edit? And my second is what is the best syntax of this->item->[correct'Method'?] (is method the correct term or variable, I'm a little shaky on this!) to use so that each list item will have an id="myID[nameofarticle/subcatagory]"
You'll see cat-children in /components/com_content/views/category/tmpl/default.php
The ul is in another loaded subtemplate, loadTemplate('children'); ?> , i.e.
/components/com_content/views/category/tmpl/default_children.php
If you want to modify the li class you could stick something like this at line 26 (of your override not core file - but fine to just test on a core file)
<?php $class = ' class="cmyId' . $this->escape($child->title) . '"';?>
That would make each li appear as
So this
<li<?php echo $class; ?>>
<?php $class = ''; ?>
becomes this
<?php $class = ' class="cmyId' . $this->escape($child->title) . '"';?>
<li<?php echo $class; ?>>
<?php //$class = ''; ?>
Have tested it out on a 2.5 installation.
You should override several files stored in components/com_content/views/
Depending on the list you want to edit, you should then look in the folders:
- article
- category
- categories
- featured
In each of these folders you'll see a subfolder called 'tmpl', inside which there is a 'default.php' file. That's what you're looking for.
If you want to override the files remember that the best practice is to place the alternative files in your template's folder, building a similar path as the one in which the original file is (e.g. for the article folder: templates/YOURTEMPLATEFOLDER/html/com_content/article/default.php - NO tmpl folder needed, nor views folder).
An alternative and, in my opinion, easier way could be setting different templates for each category, and then assigning to each the list styles you prefer.
Or, even easier, you could simply edit your index.php file in the template's folder so that it echoes a specific css stylesheet depending on the $catId.
As your HTML code shows you are using Category Blog view, each article instance in the category is being rendered by blog_children.php file, as it shows /components/com_content/views/category/tmpl/blog.php
<?php echo $this->loadTemplate('children'); ?>
So /components/com_content/views/category/tmpl/blog_children.php is the file you need to edit or override in template html directory.
Then you can apply custom styling adding an id or class for each article with $child->id.
I have created a custom image attribute and added it to default attribute set in Magento. My new attributes are img_support and img_upgrade. I've displayed both images on product view page using this piece of code:
<?php if ($_product->getimg_upgrade()):
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'img_upgrade')->resize(85).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" "/>';
echo $_helper->productAttribute($_product, $_img, 'img_upgrade');
endif;
?>
Same code with the second custom image attribute name will display img_support image. When I set images and select them for these two attributes they'll display fine but when there is no image uploaded and selected for these attributes and I try to show it on product view page then it generates an error. Something like this:
a:5:{i:0;s:25:"Image file was not found.";i:1;s:3911:"#0 C:\Program Files\EasyPHP- 5.3.8.0\www\mymagentoroot\app\code\core\Mage\Catalog\Helper\Image.php(163):
Mage_Catalog_Model_Product_Image->setBaseFile('no_selection').....
And a long trace after that. So basically it fetches the image even though there is no image selected. Can anyone tell me how can I display my custom images in product view page of selected products? I have, say 10 products with default attribute set. So all of these 10 products CAN be set with img_support and img_upgrade but I want to show the custom images only on 5 selected products. If the images are set display. Otherwise don't. How can i do this? If there is any other proper or better way to do this then help me out here.
Thanks!
When a product has no image for a given attribute, Magento uses a placeholder image instead.
Basically, each image attribute must have a placeholder image in the skin directory, named with the corresponding attribute code.
In your case, you should create two new placeholder images for your two new attributes img_support and img_upgrade, in this skin directory : images/catalog/product/placeholder/your_attribute_code.jpg (either with a new image, or with a copy of one of the base placeholders)
This problem also happens if you upload image for that attribute then suddenly remove image file via FTP. It is not good to show the site down. To summarize, there are 3 ways to fix this:
1) Answer of #blmage: use place holder
2) Use try catch:
<?php
try {
if ($_product->getimg_upgrade()):
$_img = '<img src="'.$this->helper('catalog/image')->init($_product, 'img_upgrade')->resize(85).'" alt="'.$this->htmlEscape($this->getImageLabel()).'" title="'.$this->htmlEscape($this->getImageLabel()).'" "/>';
echo $_helper->productAttribute($_product, $_img, 'img_upgrade');
endif;
}
catch (Exception $e) {
}
?>
Check if the file is existed
getBaseMediaPath();
$baseFile = $baseDir . $_product->getImgUpgrade();
if (file_exists($baseFile)) {
}
?>
My client needs a a small box on CMS pages and on Category landing pages that will show thumbnail/price/short description of a random item related to that category (separate from the grid view)
Any thoughts on what would be the best way to accomplish this?
Thanks,
-Sam
go to template/catalog/product/view/ and make a new phtml file random_product.phtml with the following code
<?php
$catId = $this->getCat_id();
$cat=Mage::getModel("catalog/category")->load($catId);
$prodCollection = $cat->getProductCollection();
$pids=array();
foreach($prodCollection as $product)
{
array_push($pids,$product->getId());
}
$randProductId=array_rand($pids);
echo $randProductId;
?>
now if your category id is for example 10, make a static block and paste the following code in the contents
{{block type="catalog/product" cat_id="10" template="catalog/product/view/random_product.phtml"}}
now when you will view the static block, you will see a random product id every time you refresh.
THen,you can write your own custom html in the phtml file after loading the product.
To load your product from here you can do $product = Mage::getModel('catalog/product')->load($randProductId); then call methods such as $product->getName() etc to get the details you need to output.
I want to add an Import button and a file browse button next to the Add Product button in the product grid page in magento admin.
When the user choose a file and clicks the Import button
I'll upload the file to var/import, open a new tab and run the import profile.
How can I add the form (import button + file browse field) to the top of the grid?
Thanks
Use XML Layouts to set your custom template for product grid container block and add your custom form block there. You need to extend adminhtml_catalog_product_index layout handle for that:
<adminhtml_catalog_product_index>
<reference name="product_list">
<!-- Set your custom template -->
<action method="setTemplate"><template>path/to/your_template.phtml</template></action>
<!-- Add your custom block -->
<block name="import_form" as="import_form" type="your_module/form_block_name"></block>
</reference>
</adminhtml_catalog_product_index>
Then you need to define your block and template. Your custom block should be extended from Mage_Adminhtml_Block_Widget_Form and template should be a copy of adminhtml/default/default/template/catalog/product.phtml but with modifications to display your custom block, like in the following example:
<div class="content-header">
<table cellspacing="0">
<tr>
<td style="width:50%;"><h3 class="icon-head head-products"><?php echo Mage::helper('catalog')->__('Manage Products') ?></h3></td>
<td class="a-right">
<?php echo $this->getButtonsHtml() ?>
</td>
</tr>
</table>
</div>
<!-- Start of Displaying of your custom import form -->
<?php echo $this->getChildHtml('import_form');?>
<!-- End of Displaying of your custom import form -->
<?php if( !$this->isSingleStoreMode() ): ?>
<?php echo $this->getChildHtml('store_switcher');?>
<?php endif;?>
<div>
<?php echo $this->getGridHtml() ?>
</div>
you can use Mage_Adminhtml_Block_Widget_Container::addButton() to do this. Search magento's code for calls to this function to see how it should be used, create your own container block, replace magento's container block for the product with it by using a layout file and you're done.
Hi
thats right use Mage_Adminhtml_Block_Widget_Container::addButton() method & here is the syntax
$data = array(
'label' => 'Import Zipcode Data',
'onclick' => "setLocation('".$this->getUrl('*/*/import')."')"
);
$this->addButton ('import_zip_code', $data, 0, 100, 'header', 'header');
of course u can have any label & id of button that u want. setLocation allows u to set the target where u want to go when u click on this button.