- EDITED **
Hello I am new to PHP and trying to figure out a hack for a Joomla module.
For some reason the ‘else’ statement is not working. I don’t understand why…
<? if (KRequest::get('get.view', 'string') != 'event' || isset($module)) : ?>
<? $desc = $event->description; ?>
<? $desc = preg_replace("/\{[^\)]+\}/","", $desc) ?>
<? $desc = substr(strip_tags($desc, '<p><ul><li><b><i><strong><br>'), 0, 180)?>
<? if (strlen($desc) == 180) $desc .= '...'; ?>
<div itemprop="description" class="ohanah-event-short-description">
<?=$desc?>
</div>
<? else : ?>
<!--here is where I want to end it --!>No description.
<?
$description = $event->description;
// Create temporary article
$item =& JTable::getInstance('content');
$item->parameters = new JParameter('');
$item->text = $description;
$joomlaVersion = JVersion::isCompatible('1.6.0') ? '1.6' : '1.5';
if ($joomlaVersion == '1.5') {
$results = JFactory::getApplication()->triggerEvent('onPrepareContent', array (&$item, &$params, 1));
} else {
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('content');
$results = $dispatcher->trigger('onContentPrepare', array ('com_content.article', &$item, &$params, 1));
}
$description = $item->text;
?>
<div style="display:none"><span itemprop="name"><?=$event->title?></span></div>
<div itemprop="description" class="full-description">
<?=$description?>
</div>
<? endif ?>
Braces are wrong. Should be like this (or similar – not sure about where you need $desc):