I'm working on magento and I want the categories that appear on left to be appeared on right side. I tried many tutorial, but didnt get it. Please help me on this. I'm new to magento. Thanks.
To add categories into the sidebar firstly go to:
app/design/frontend/default/YOURTHEME/template/catalog/navigation
and create a .phtml file, for example: left-nav.phtml
In left-nav.phtml put this:
<div class="category-nav">
<div class="block-content">
<p class="block-subtitle"><?php echo $this->__('Categories') ?></p>
<ul id="nav_category" class="nav_category">
<?php foreach ($this->getStoreCategories(true) as $_category): ?>
<?php echo $this->drawItem($_category) ?>
<?php endforeach ?>
</ul>
</div>
</div>
This just loops through all the enabled categories and outputs them into a list.
Now you need to link up the list so firstly go into /public_html/app/design/frontend/default/sbs/layout/page.xml
Find the bit for 2columns-left, or right if you want it to output on the right. In the layout you are using find:
<block type="core/text_list" name="left" as="left" translate="label">
Inside the block add a line of code like this:
<block type="catalog/navigation" name="category.listing" as="left_nav" before="-" template="catalog/navigation/left_nav.phtml" />
The before=”-“ just adds it before everything else.
Finally go into:
/public_html/app/design/frontend/default/YOURTHEME/template/page/2columns-left.phtml and add:
<?php echo $this->getChildHtml('left_nav') ?>
Note:
You will need to clean the cache for this to work.
I have written a more in depth answer on my website http://brideo.co.uk/moving-categories-to-left-collumn-magento/
Related
I have some code and I'm trying to add a line-break, than the date. In the current code it shows the date than the title on the same line.
Can someone help?
<div class="post-title">
<?php the_title('<div class="entry-title title-h4">', '</span></div>'); ?>
</div>
All help is appreciated! The date and text line is at the end of the code block.
Edit: I have managed to reverse the data successfully, but the date is no longer styled properly and doesn't follow the correct style. How do I move the date and keep it styled? Here's the code I ended up with:
<div class="post-title">
<?php the_title('<div class="entry-title title-h4">', '</span></div>'.(!$params['hide_date'] ? get_the_date('d M').': ' : '')); ?>
</div>
Edit 2:
I've gotten a little further. I successfully placed the date at the end of the text and kept it styled. But I'd like to have it under the title, I want to add a line-break. Anyone? Here's the code I ended up with:
<div class="post-title">
<?php the_title('<div class="entry-title title-h4">', '</span>'.(!$params['hide_date'] ? get_the_date('d M').' ' : '').'</div>'); ?>
</div>
I figured it all out by myself. Figured I'd post the answer here in-case someone needed this someday.
<div class="post-title">
<?php the_title('<div class="entry-title title-h4">', '</span>'.'<br>'.(!$params['hide_date'] ? get_the_date('d M').' ' : '').'</div>'); ?>
</div>
I have asked a similar question in the past but still have issues...
I am therefore placing the whole function here.
Can anyone tell me how to change the format that the date is output?
Currently it shows 20130731
I want it to show 31st July 2013
function le_detail() {
?>
<div class="event">
<!--Standard WP - use 'echo' -->
<h2 class="button"> <?php echo get_the_title(); ?> </h2>
<!-- ACF - NO 'echo' -->
<h3><?php the_field('where'); ?></h3>
<h3><?php the_field('when'); ?></h3>
<p><?php the_field('description'); ?></p>
<p>Chairman: <?php the_field('chairman'); ?></p>
</div>
<?php
}
The date is the line: (this is using the Advanced Customs Fields plugin)
<h3><?php the_field('when'); ?></h3>
Yes, I had this same problem until I tried it this way:
$date = DateTime::createFromFormat('Ymd', get_field('my_datefield'));
//use your field name
then...
<li>Ticket Date: <?php echo $date->format('d M, Y'); ?> </li>
Good Luck!
ACF plugin is having get_field('') function to get the value of the custom field. Since you have used 'when' as the field name, so do as follows:
<h3><?php echo date("dS F,Y",strtotime(get_field('when'))); ?></h3>
Use the above code snippet, that will solve your problem.
and thanks in advance for your help. I'm using Simplepie to try to bring this feed:
http://www.p2rx.org/webservices/rssNews.cfm?Type=Tribal&getall=true
into this page:
http://www.tribalp2.org/events/news.php
As you can see, it isn't working. Although many other feed urls I've entered into:
$feed->set_feed_url('http://www.p2rx.org/webservices/rssNews.cfm');
work just fine. I've added
$feed->force_feed(true);
as well. What might the problem be? The full code is:
<?php
require_once('../php/autoloader.php');
$feed = new SimplePie();
$feed->set_feed_url('http://www.p2rx.org/webservices/rssNews.cfm?Type=Tribal&getall=true');
$feed->force_feed(true);
$feed->init();
$feed->handle_content_type();
?>
<?php foreach ($feed->get_items(0,30) as $item): ?>
<div class="item">
<h4><?php echo $item->get_title(); ?> - <?php echo $item->get_date('F j, Y'); ?></h4>
<p><?php echo $item->get_description(); ?></p>
</div>
<?php endforeach; ?>
<?php unset($feed); ?>
Thanks.
SimplePie can not display all feeds. There are crap feeds that do not follow the standards and even if you try to force it, SimplePie can not decipher them. However checking http://validator.w3.org/feed/ your feed validates.
Try not forcing feed, also try calling force feed after init. If the feed validates SimplePie should handle it.
I am new to Zend Framework and I have a question about something I am trying to do.
The main content of most pages of the application that I am working on will consist of 1 or more div elements that need to be styled the same.
Here is an example of the HTML that I want to generate:
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class='google-vis-table'></div>
<form id='locations'>
...
</form>
</div>
</div>
I know I can easily do this by pushing the form to my view script in my controller then adding this code to my controller.
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class="google_vis_table"></div>
<?php
echo $this->formLocations;
?>
</div>
</div>
But that is not DRY.
The example I used here has a Google Visualization Table and a Zend Form in it's content. Sometimes the panels will need to contain a form. Sometimes they won't, so I don't think form decorators are the way to go. So basically, the id of the panel, the panel header text and the content of div class='panel-content' need to be dynamic. Everything else will stay the same from panel to panel.
What is my best option here?
You might want to consider using partials:
http://framework.zend.com/manual/en/zend.view.helpers.html#zend.view.helpers.initial.partial
For example, you could have an admin-locations.phtml partial that contains:
<div id='admin-locations' class='panel'>
<header class="panel-header">
<h2>Locations</h2>
</header>
<div class='panel-content'>
<div id='locations-table' class="google_vis_table"></div>
<?php echo $this->form; ?>
</div>
</div>
Now you can simply repeatedly call the partial within a view, with or without supplying a form:
...
echo $this->partial('admin-locations.phtml');
echo $this->partial('admin-locations.phtml', array('form' => $this->yourForm);
echo $this->partial('admin-locations.phtml');
...
Hope this helps.
I got few issues proting a pear based form to zend form.
I have few elements I need :
Basic Elements
Groups
Group Elements
Sections
I previously used templates to render the forms on Pear. I obviously cannot use pre-existing zend decorators, since I need to specify css classes for each of the components of my base elements.
To see the issue I need to render this, which is the template for a basic element :
<li class = "{position_in_the_form} {error}">
<label class="{label_class}"> {label}
[<span class="required_class"> * </span>]
</label>
<div> {element_content} </div>
[<p class = "{error_class}"> {error_message} </p>]
</li>
So as you can see I have many dynamic things I would like to be able to specify : position in the form, class for the label, class for the required section, the class for the error.
I would also like to be able to specify this from an ini file. I manage to set up the basic meta from the ini but not custom fields.
One of the reason I cannot use basic decorators is that I need to have "error" in the "li" class when there is an error in the element or the sub_form.I'm not sure this is possible with the error decorator... (correct me if I'm wrong)
Also, for the group I need something handling the errors, and since the core groups don't handle errors I need to subclass the sub_form. But how can I create a subform in an ini file and I don't know how to provide parameters to the sub form fromn the ini.
The main idea here is to be able to have visual and logic groups of elements in a form. For example I need a 'name' group with fullname, middle name, etc. This also implies a global validator for this "name" group.
An other thing is that I want to be able to position these groups : left half, right half, full
I got the css ready for this and working with pear.
So what I need is a simple solution, with few code and ini configurations. Unfortunately I think I got stuck in something too complicated, so if someone has any idea about a simple architecture it would be amazing!
Thanks in advance for your help,
Best, Boris
In your complex decoration need, you might want to use the ViewScript Zend_Form_Element_Decorator
$element->setDecorators(array(
array('ViewScript', array('viewScript' => 'path/to/your/views/element.phtml')),
));
and then in path/to/your/views/element.phtml, more or less something like
<li class="<?php echo $this->element->getAttrib('position_in_the_form') ?> <?php echo $this->element->hasErrors() ? 'error' : '' ?>">
<label class="<?php echo $this->element->getAttrib('label_class') ?>">
<?php echo $this->formLabel($this->element->getName(),
$this->element->getLabel()) ?>
<? if ( $this->element->isRequired() ) { ?>
[<span class="required_class"> * </span>]
<? } ?>
</label>
<div> <?php echo $this->{$this->element->helper}(
$this->element->getName(),
$this->element->getValue(),
$this->element->getAttribs()
) ?> </div>
<? if ( $this->element->hasErrors() ) { ?>
[<p class="<?php echo $this->element->getAttrib('error_class') ?>"> <?php echo $this->formErrors($this->element->getMessages()) ?> </p>]
<? } ?>
</li>
This is only a drafty snippet of code, but should lead you in the direction you aim.
Regards