I have this code in PHP
<?php foreach($this->group('filter') as $i => $fields): ?>
<?php $newField = $this->field('name#'.$i)->value(); ?>
<?php $finalvar = explode(",", $newField); ?>
<a data-filter=<?php foreach($finalvar as $fletter) : ?>".filter_<?php echo standardize($fletter); ?>">
<?php endforeach; ?>
<?php if($this->field('icon#'.$i)->value()): ?><i class="<?php echo $this->field('icon#'.$i)->value(); ?>"></i><?php endif; ?>
<span class="name"><?php if($this->field('label_items#'.$i)->value()): ?><?php echo $this->field('label_items#'.$i)->value(); ?><?php else: ?><?php echo $this->field('name#'.$i)->value(); ?><?php endif; ?>
</span>
</a>
<?php endforeach; ?>
PHP code works but I have a problem on the HTML code. The generated HTML code is this:
<a data-filter=".filter_country">
".filter_capital;
<span class="name">Australia</span>
</a>
My goal is to implement this one:
<a data-filter=".filter_country,.filter_capital"
<span class="name">Australia</span>
</a>
I know it's something in front of me but I cannot see it. Does anyone have an idea concerning the syntax?
Check your syntax:
<?php foreach ($this->group('filter') as $i => $fields) : ?>
<?php $newField = $this->field('name#' . $i)->value(); ?>
<?php $finalvar = explode(",", $newField); ?>
<a data-filter="
<?php
$i = 1;
foreach ($finalvar as $fletter) { ?>
.filter_<?php echo standardize($fletter); ?>
<?php if ($i < count($fletter)) { ?>, <?php } ?>
<?php $i++; } ?>
">
<?php if ($this->field('icon#' . $i)->value()) : ?><i class="<?php echo $this->field('icon#' . $i)->value(); ?>"></i><?php endif; ?>
<span class="name"><?php if ($this->field('label_items#' . $i)->value()) : ?><?php echo $this->field('label_items#' . $i)->value(); ?><?php else : ?><?php echo $this->field('name#' . $i)->value(); ?><?php endif; ?>
</span>
</a>
<?php endforeach; ?>
Related
This is the loop I want to limit this to 2 outputs and create another loop for further outputs please help.. I am a beginner
Enter code here
<?php if ($informations) { ?>
<div class="column">
<h3>
<?php echo $text_information; ?>
</h3>
<ul>
<?php foreach ($informations as $information){ ?>
<li><a href="<?php echo $information['href']; ?>">
<?php echo $information['title']; ?>
</a></li>
<?php } ?>
</ul>
</div>
<?php } ?>
Try this. .
<?php if ($informations) { ?>
<div class="column">
<h3><?php echo $text_information; ?></h3>
<ul>
<?php
$i=1;
foreach ($informations as $information){
if($i==2)
{
break;
}
?>
<li><?php echo $information['title']; ?></li>
<?php
$i++;
} ?>
</ul>
</div>
<?php } ?>
For other values . .
<?php if ($informations) { ?>
<div class="column">
<h3><?php echo $text_information; ?></h3>
<ul>
<?php
$i=1;
foreach ($informations as $information){
if($i<2)
{
continue;
}
?>
<li><?php echo $information['title']; ?></li>
<?php
$i++;
} ?>
</ul>
</div>
<?php } ?>
Bit vague but I guess you are looking for array_chunk,
$new_array = array_chunk($informations, 2, true);
Consider the following loop:
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<div class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</div>
<?php endif; ?>
<?php endforeach; ?>
I wanted to wrap the first 12 items in a div and then the last 2 items in a div. The problem is there are not always 12 items exactly in the first div. There can be between 2 AND 12 items.
How would I manipulate this loop to achieve such? Many thanks
Just use a counter inside the loop to see how many times you've been through it.
<?php $count = 1; ?>
<?php $break= count($this->item->extra_fields) - 2; ?>
<?php echo "<div>"; ?>
<?php foreach ($this->item->extra_fields as $key=>$extraField): ?>
<?php if($extraField->value != ''): ?>
<div class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
<span class="itemExtraFieldsValue"><?php echo $extraField->value; ?></span>
</div>
<?php $count++; ?>
<?php endif; ?>
<?php if ($count == $break) : ?>
<?php echo "</div><div>"; $count ==0; ?>
<?php endif; ?>
<?php endforeach; ?>
<?php echo '</div>'; ?>
i installed SJ Financial Template joomla on my website caindiagroup.com,
but when i open article blog on my website, it show an error on sj_financial/html/com_content/category/blog_item.php file..
Fatal error: Class 'JLayoutHelper' not found in /home/caind126/public_html/templates/sj_financial/html/com_content/category/blog_item.php on line 25
Fatal error: Class 'JLayoutHelper' not found in /home/caind126/public_html/templates/sj_financial/html/com_content/category/blog_item.php on line 27
Fatal error: Class 'JLayoutFile' not found in /home/caind126/public_html/templates/sj_financial/html/com_content/category/blog_item.php on line 103
Fatal error: Call to a member function render() on a non-object in /home/caind126/public_html/templates/sj_financial/html/com_content/category/blog_item.php on line 104
My file Code is
`<?php
/**
* #package Joomla.Site
* #subpackage Layout
*
* #copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* #license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;?>
<?php
// Create a shortcut for params.
$params = $this->item->params;
$images = json_decode($this->item->images);
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
$canEdit = $this->item->params->get('access-edit');
JHtml::_('behavior.tooltip');
JHtml::_('behavior.framework');
?>
<?php if ($this->item->state == 0) : ?>
<span class="label label-warning"><?php echo JText::_('JUNPUBLISHED'); ?></span>
<?php //intro images ?>
<?php echo JLayoutHelper::render('joomla.content.intro_image', $this->item); ?>
<div class="article-text">
<?php echo JLayoutHelper::render('joomla.content.blog_style_default_item_title, $this->item'); ?>
<?php if (!$params->get('show_intro')) : ?>
<?php echo $this->item->event->afterDisplayTitle; ?>
<?php endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php if ($params->get('show_intro')) : ?>
<?php echo $this->item->introtext; ?>
<?php endif; ?>
<div class="item-headinfo">
<?php if (!$params->get('show_intro')) : ?>
<?php echo $this->item->event->afterDisplayTitle; ?>
<?php endif; ?>
<?php echo $this->item->event->beforeDisplayContent; ?>
<?php // to do not that elegant would be nice to group the params ?>
<?php if (($params->get('show_author')) or ($params->get('show_category')) or ($params->get('show_create_date')) or ($params->get('show_modify_date')) or ($params->get('show_publish_date')) or ($params->get('show_parent_category')) or ($params->get('show_hits'))) : ?>
<dl class="article-info muted">
<!--<dt class="article-info-term"><?php //echo JText::_('COM_CONTENT_ARTICLE_INFO'); ?></dt>-->
<?php endif; ?>
<?php if ($params->get('show_parent_category')) : ?>
<dd class="parent-category-name">
<?php $title = $this->escape($this->item->parent_title);
$url = '' . $title . ''; ?>
<?php if ($params->get('link_parent_category')) : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $url); ?>
<?php else : ?>
<?php echo JText::sprintf('COM_CONTENT_PARENT', $title); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_create_date')) : ?>
<dd class="create">
<i class="icon-calendar"></i>
<?php echo JText::sprintf( JHTML::_('date',$this->item->created, JText::_('DATE_FORMAT_LC'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_modify_date')) : ?>
<dd class="modified">
<i class="icon-calendar"></i>
<?php echo JText::sprintf('COM_CONTENT_LAST_UPDATED', JHTML::_('date',$this->item->modified, JText::_('DATE_FORMAT_LC'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_publish_date')) : ?>
<dd class="published">
<i class="icon-calendar"></i>
<?php echo JText::sprintf('COM_CONTENT_PUBLISHED_DATE', JHTML::_('date',$this->item->publish_up, JText::_('DATE_FORMAT_LC'))); ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_author') && !empty($this->item->author )) : ?>
<dd class="createdby">
<?php $author = $this->item->author; ?>
<?php $author = ($this->item->created_by_alias ? $this->item->created_by_alias : $author);?>
<?php if (!empty($this->item->contactid ) && $params->get('link_author') == true):?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY' ,
JHTML::_('link',JRoute::_('index.php?option=com_contact&view=contact&id='.$this->item->contactid),$author)); ?>
<?php else :?>
<?php echo JText::sprintf('COM_CONTENT_WRITTEN_BY', $author); ?>
<?php endif; ?>
</dd>
<?php endif; ?>
<?php if ($params->get('show_hits')) : ?>
<dd class="hits">
<?php echo JText::sprintf('COM_CONTENT_ARTICLE_HITS', $this->item->hits); ?>
</dd>
<?php endif; ?>
<?php if ($this->params->get('show_tags', 1)) : ?>
<dd class="item-tags">
<?php $this->item->tagLayout = new JLayoutFile('joomla.content.tags'); ?>
<?php echo $this->item->tagLayout->render($this->item->tags->itemTags); ?>
</dd>
<?php endif; ?>
<?php if (($params->get('show_author')) or ($params->get('show_category')) or ($params->get('show_create_date')) or ($params->get('show_modify_date')) or ($params->get('show_publish_date')) or ($params->get('show_parent_category')) or ($params->get('show_hits'))) :?>
</dl>
<?php endif; ?>
</div>
<?php if ($params->get('show_readmore') && $this->item->readmore) :
if ($params->get('access-view')) :
$link = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid));
else :
$menu = JFactory::getApplication()->getMenu();
$active = $menu->getActive();
$itemId = $active->id;
$link1 = JRoute::_('index.php?option=com_users&view=login&Itemid=' . $itemId);
$returnURL = JRoute::_(ContentHelperRoute::getArticleRoute($this->item->slug, $this->item->catid));
$link = new JURI($link1);
$link->setVar('return', base64_encode($returnURL));
endif; ?>
<a class="readmore" href="<?php echo $link; ?>">
<?php if (!$params->get('access-view')) :
echo JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
elseif ($readmore = $this->item->alternative_readmore) :
echo $readmore;
if ($params->get('show_readmore_title', 0) != 0) :
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif;
elseif ($params->get('show_readmore_title', 0) == 0) :
echo JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
else :
echo JText::_('COM_CONTENT_READ_MORE');
echo JHtml::_('string.truncate', ($this->item->title), $params->get('readmore_limit'));
endif; ?>
<i class="ico-arrow-right"></i>
</a>
<?php endif; ?>
</div>
<?php if ($this->item->state == 0) : ?>
</div>
<?php endif; ?>
<?php echo $this->item->event->afterDisplayContent; ?>`
Plz help me..
I'm not sure if it helps, but you can try to add following line just after defined('_JEXEC') or die;
require_once(JPATH_ROOT . '/libraries/cms/layout/helper.php');
I'm trying to add a simple string to the display price in Magento. Currently the price displays as $##.## by default. I would like it to read: Price: $##.##
A simple search of the displayed prices brought me to template/catalog/product/price.phtml. This file seems to control price display when there are variables involved. IE, price including tax, excluding tax, special prices, etc...
Which file is controlling the displayed price when there are no variables involved, the default price:
<span class="price">$##.##</span>
Once I figure out where this is located, I'm confident I can append a simple string before the displayed price.
Thanks in advance.
OK. I was suggesting in the comments not to get lost in the if-else statements but I just did also for a few minutes. Finally found it.
Inside this if statement
<?php if ($_finalPrice >= $_price): ?>
there is an other if:
<?php if ($_taxHelper->displayBothPrices()): ?>
On the else statement of this last if there is the part you are looking for.
<?php if ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 0)): // including ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 1)): // incl. + weee ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<span class="weee">(
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
)</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 4)): // incl. + weee ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<span class="weee">(
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<?php echo $_weeeSeparator; ?>
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount() + $_weeeTaxAttribute->getTaxAmount(), true, true); ?>
<?php $_weeeSeparator = ' + '; ?>
<?php endforeach; ?>
)</span>
<?php elseif ($_weeeTaxAmount && $_weeeHelper->typeOfDisplay($_product, 2)): // excl. + weee + final ?>
<span class="regular-price"><?php echo $_coreHelper->currency($_price,true,true) ?></span><br />
<?php foreach ($_weeeTaxAttributes as $_weeeTaxAttribute): ?>
<span class="weee">
<?php echo $_weeeTaxAttribute->getName(); ?>: <?php echo $_coreHelper->currency($_weeeTaxAttribute->getAmount(), true, true); ?>
</span>
<?php endforeach; ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php echo $_coreHelper->currency($_price + $_weeeTaxAmount, true, true) ?>
</span>
<?php else: ?>
<span class="regular-price" id="product-price-<?php echo $_id ?><?php echo $this->getIdSuffix() ?>">
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
</span>
<?php endif; ?>
Each part in this code shows a regular price, depending on the tax settings. Most probably you need only the last part.
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
i'm on magento 1.8, and developing on nearly plain system, when debugging, i'm on
<?php if ($_finalPrice == $_price): ?>
<?php echo $_coreHelper->currency($_price, true, true) ?>
<?php else: ?>
<?php echo $_coreHelper->currency($_finalPrice, true, true) ?>
<?php endif; ?>
round about line 201
I'm trying to create a link based on a URL variable using only the last five digits of its respective line of XML data.
For example, if the XML link is http://events.stanford.edu/events/213/21389 how can I create this link a href="e/?i=21389?
Here's my page, XML and code:
<?php
// Build the XML file path, using URL variable $c (above)
$c = $_GET['c'];
$p ="http://events-prod.stanford.edu/xml/byCategory/";
$e = "/mobile.xml";
$file = "$p$c$e";
$xml = simplexml_load_file($file);
?>
<h1><?php echo $xml->title; ?></h1>
Home
</div><!-- /header -->
<div data-role="content">
<?php // Only display if there are events ?>
<?php if (isset($xml->Event->title)) { ?>
<ul data-role="listview">
<?php foreach($xml->Event as $event) { ?>
<li>
<a href="<?php echo $event->link; ?>">
<?php if ($event->Media->url != null) { ?>
<img src="<?php echo $event->Media->url;?>" alt="<?php echo $event->title;?> thumbnail" />
<?php } ?>
<h3><?php echo $event->title; ?></h3>
<p><strong><?php echo $event->beginDate; ?> at <?php echo $event->beginTime; ?></strong></p>
<p><?php echo $event->locationText; ?></p>
</a>
</li>
<?php } ?>
</ul>
<?php } else { ?>
<?php echo '<p>There is currently nothing scheduled for ', $xml->title, '.</p>';?>
<?php } ?>
I'm using short tags, because I think you'll agree it's easier now to read the code as oppose to before.
<?
$controller ="http://events-prod.stanford.edu/xml/byCategory/";
$category_id = $_GET['c'];
$category_id = 0;
$xml = "/mobile.xml";
$url = $controller . $category_id . $xml;
$xml_object = simplexml_load_file($url);
?>
<div>
<h1><?= $xml_object->title ?></h1>
Home
</div>
<div data-role="content">
<? if (!empty($xml_object->Event->title)): ?>
<ul data-role="listview">
<? foreach($xml_object->Event as $event): ?>
<li>
<?
$pattern = '/[0-9]+$/';
$matches = array();
preg_match($pattern, $event->link, $matches);
$my_link = 'e/?i=' . $matches[0];
?>
<a href="<?= $my_link ?>">
<? if (!empty($event->Media->url)): ?>
<img src="<?= $event->Media->url ?>" alt="<?= $event->title ?> thumbnail" />
<? endif; ?>
<h3><?= $event->title ?></h3>
<p><strong><?= $event->beginDate ?> at <?= $event->beginTime ?></strong></p>
<p><?= $event->locationText ?></p>
</a>
</li>
<? endforeach; ?>
</ul>
<? else: ?>
<? echo '<p>There is currently nothing scheduled for ', $xml_object->title, '.</p>'; ?>
<? endif; ?>
</div>