Magento - Add own phtml with getChildHtml - magento

In 1column.phtml i added the follow line:
<div id="ja-container" class="ja-lo-1col wrap">
<?php echo $this->getChildHtml('storeinfo.pthml'); ?>
I added the storeinfo.phtml file to the page/html folder. I know i have to add something to an xml file, but i have no idea what. Does someone knows what i have to do, to make it work?
storeinfo.phtml contains:
<div class="storeinfo">
<p class="StoreName"><?php echo Mage::app()->getStore()->getName(); ?></p>
<br/>
<?php echo Mage::getStoreConfig('design/head/default_description'); ?>
</div>

You have to first make an entry in your layout XML as given below:
<block type="module/file" name="myblock" as="myblock" template="PATH_TO_storeinfo.phtml"/>
and then you can use following line in your phtml file where you want that phtml to be included:
<?php echo $this->getChildHtml('myblock'); ?>
where myblock is the name and alias for your block defined in the layout XML.

The getChildHtml() function fetches the child block in a parent block.
For example:
<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
<block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
</block>
The code above is the layout for ‘catalog/product/view.phtml’, here you can use
$this->getChildHtml('media')
to fetch the media block and output it in the place where the function is called. The child block which you need to output in the parent file should have an argument named ‘as’, which you would use in the getChildHtml() function.

you can addd below code to your local.xml or any module layout xml
<default>
<reference name="footer">
<block type="core/template" name="storeinfo" template="storeinfo.phtml"/>
</reference>
</default>
please check your template path as well.
hope this will help you.

Related

How to call a static block of magento extension in .phtml file?

I have installed an extension for slider on my home page. It has given me a static block code.
Call via block:
{{block type="responsivebannerslider/index" name="responsivebannerslider_index" template="responsivebannerslider/index.phtml"}}
Dont know how call it in .phtml file?
You can call it from your template by creating a block on the layout directly in the phtml template file:
<?php echo $this->getLayout()->createBlock('responsivebannerslider/index')->setTemplate('responsivebannerslider/index.phtml')->toHtml(); ?>
Or if the block is listed in the extensions layout XML file, (which would be nested within a reference node), and would look something like:
<block type="responsivebannerslider/index" name="responsivebannerslider_index" as="an_alias" template="responsivebannerslider/index.phtml">
<label>Responsive banner</label>
</block>
And you'd call that in your template file like:
<?php echo $this->getChildHtml('an_alias'); ?>
<?php echo $this->getLayout()->createBlock('responsivebannerslider/index')->setTemplate('responsivebannerslider/index.phtml')->toHtml(); ?>

Import variable from bleg to aleg‏

I need to import a variable from b-leg to a-leg but renaming. I use the parameter
<action application="set" data="import=this_is_a_variable_name"/>
https://wiki.freeswitch.org/wiki/Variable_import
The problem is that I can not change the name of the variable. Change the value of the variable in aleg.
Is this possible?

Magento category description

I have the following problem.
My category description above (before the goods).
I wish to change the location of the category description. This should be at the bottom (after the goods).
I am using magento commerce 1.9
You need to find the category template, which should be in your theme directory here;
app/design/frontend/XXX/YYY/template/catalog/category/view.phtml
Where XXX YYY is the directory of the template you are using. If there is no view.phtml file in there, magento will fall back to the base version here;
app/design/frontend/base/default/template/catalog/category/view.phtml
I suggest you copy it to your theme directory if it wasnt there.
Now, open that file and find this;
<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description std">
<?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?>
</div>
<?php endif; ?>
And simply move it to the end of the file.

Joomla Template and Foundation 5 Framework

I have created a basic template for Joomla using Foundation 5 Framework but the call to include Foundation and jQuery and the call to fire Foundation needs to be the last part that is loaded.
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/bower_components/foundation/js/foundation.min.js"></script>
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/bower_components/jquery/jquery.js"></script>
<script src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/js/app.js"></script>
So I have added them into the template and they can be navigated to when I load the template up but for some reason foundation does not exist according to firebug and won't load.
If Firebug is saying that the file does not exist then you have used the incorrect path. As for the importing of jQuery, I would recommend you use the Joomla standards for this which will also import the file that comes package use noConflict() mode like so >> JHtml::_('jquery.framework');
Also try using the addScript() method for importing your other scripts, however please ensure that the paths are correct. So your full code will look like this:
<?php
JHtml::_('jquery.framework');
JHtml::_('script', JUri::root() . 'templates/template_name/bower_components/foundation/js/foundation.min.js');
JHtml::_('script', JUri::root() . 'templates/template_name/js/app.js');
?>
Currently, your .js files are within the template folder, however are within different sub-folders, thus I would recommend sticking to 1 main folder for all javascript files.
Update:
I have just tested Foundations and it works fine for me. First of all, you need to ensure that jQuery is loaded first. Add the following code before the ending ` tag in your template index.php file:
<script src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/bower_components/jquery/jquery.js"></script>
<script src="<?php echo $this->baseurl; ?>/templates/<?php echo $this->template; ?>/bower_components/foundation/js/foundation.min.js"></script>
<script> $(document).foundation(); </script>
Hope this helps

how can I change the header logo to link to an external website in magento?

I'm trying to achieve the following:
our client needs the header logo of his magento site to take him to another website (different domain).. I have tried to alter header.phtml but the link is becoming: www.websitedomain.com/index.php/www.otherdomain.com
what I want is simply to navigate to www.otherdomain.com
how is that possible?
You will want to change the link in the image to go to the appropriate location.
I believe the file should be located in:
/app/design/frontend/yourtemplate/yourtemplate/page/html/header.phtml
use http:// like bellow
http://www.otherdomain.com in your anchor tag
Just in case someone else comes here looking for the answer, in the file named above, at line 105 (v1.9.2) -
Add the url as below
<h1 class="logo"><strong class="no-display"><?php echo $this->getLogoAlt() ?></strong><img src="<?php echo $logo_src ?>" alt="<?php echo $this->getLogoAlt() ?>" /></h1>

Resources