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

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(); ?>

Related

Img Src path adding / when using .SVG in Cakephp

For some reason unknown to me when I try to use a .svg file in the image src path cakephp adds an additional / to the file path which shows the image as missing.
example:
<img src="<?php e($html->url('/img/mobile/shark.svg')); ?>"
outputs:
<img src="host/img/mobile/shark.svg/"
It then thinks the file is not there. But when I remove the / in chrome inspect the file appears. Anyone see this issue before?
Update 5/1
On Cake 1.3, and beyond our control at the moment to update. These helpers just break the page =( and after looking at the documentation for 1.3 it looks like it should not.
Create a image tag using cakephp helper,
<?php echo $this->Html->image('example.svg', array('alt' => 'CakePHP')); ?>
Output will be
<img src="/img/example.svg" alt="CakePHP" />
Look HtmlHelper::image(string $path, array $options = array())
You should use the CakePhp HTML helper.
<?php echo $this->Html->image('image.svg', array('alt' => 'image')) ?>

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.

Magento - Add own phtml with getChildHtml

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.

Include other .tpl in a .tpl file Prestashop

I'm usinh a Prestashop 1.5.4.1, and I would like to call a module in other module (precisely I need to use slider module just above the home featured products). I tried to call it via
include file='../directory/module.tpl'
but always I get only blank page without any code. I also tried with different ways of directory statement, but always the result was the same. Is there any possibility to include new module in correct way?
For this to work, your directory structure should be (Using PrestaShop 1.6):
-- mymodule.php
-- views
---- templates
------ hook
------ displayFooBarTemplate.tpl
-------- inc
---------- foo.tpl
---------- bar.tpl
Absolute way:
From your main module file:
protected function displayFooBarTemplate()
{
global $smarty;
...
$smarty->assign('module_templates', dirname(__FILE__).'/views/templates/');
return $this->display(__FILE__, 'displayFooBarTemplate.tpl');
}
then in your tpl file (displayFooBarTemplate.tpl):
{include file="{$module_templates}hook/inc/modal/foo.tpl"}
{include file="{$module_templates}hook/inc/modal/bar.tpl"}
Relative way (my favorite):
{include './inc/foo.tpl'}
{include './inc/modal/bar.tpl'}
What worked for me in Prestashop 1.6 is
{include file="$tpl_dir/modules/blocknewsletter/blocknewsletter.tpl"}
I put this in the footer.tpl file and correctly displayed the text box for subscribing to the newsletter. I suppose it works for all other modules, too.
Proper way to include a smarty tag includes using the curl brackets.
{include file='directory/module.tpl'}
Note that the directory in the include statement should be relative to the templates directory.
http://www.smarty.net/docsv2/en/language.function.include.tpl
In your php code declare a variable like this :
$this->path_to_tpl_folder = str_replace('\\', '/', _PS_MODULE_DIR_) . 'mon_module/tpl';
$this->context->smarty->assign('tpl_path', $this->path_to_tpl_folder)
Then in your smarty template :
{include file=$tpl_path/my_file.tpl}
Compatible with Prestashop 1.4 and 1.5.

Codeigniter base_url() in whack?

I was trying to set up a basic log in form with a following code:
<?=form_open(base_url() . 'main/login'); ?>
However after submitting the form the url shows this:
example.com/main/http//example.com/http//example.com/main/login
So I guess in essence for some reason the base-url is printed twice before the controller/method declaration. If I clear the base url value in my config file then the application works normally. I am however curious on what could cause this. For additional information I am working on xampp with a virtualhost and I have mod-rewrite on with a .htaccess file located at the document root.
CodeIgniter automatically adds the base_url to the action of the form when you use the form helper.
For example, you can use:
<?=form_open('main/login'); ?>
which will produce:
http//example.com/main/login
And a correct URL! Pretty simple! :D
More information at:
http://codeigniter.com/user_guide/helpers/form_helper.html
The file config.php under application/config has the setting:
$config['base_url'] = '';
Give it the folder/directory path. For example:
$config['base_url'] = 'http://localhost/ci_test/';
Don't forget to mention the protocol (http://). Alternatively try the site_url() method instead of base_url() for form opening. Skip it if using the form_open() function:
<form action="<?php echo site_url('main/login'); ?>"> ... </form>
Or
<?php form_open('main/login'); ?>
For more help: http://codeigniter.com/user_guide/helpers/url_helper.html
Not sure about the .htaccess file you have used. But this might be the answer codeigniter: why is that when i echo base_url() in an href attribute of an anchor tag, it echoes twice
Try it by parameter:
<?=form_open(base_url('main/login')); ?>
or
<?=form_open site_url('main/login')); ?>
In order to append the prefix also
You can Use
<?php echo form_open(base_url(main/login)); ?>
You have to use "echo" rather than because it not works in some browsers....

Resources