/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//Write conditional code for a homepage <?php if (JRequest::getVar('view')=='frontpage') { ?> put the HTML for the banner here <?php } ?> //Write conditional code for a Section Page <?php if (JRequest::getVar('view')=='section') { ?> put the HTML for the banner here <?php } ?> //Target a Section page with a particlar #id <?php if (JRequest::getVar('view')=='section' && JRequest::getVar('id')==1) { ?> put the HTML for the banner here <?php } ?> //If on section 1, display this data, if on section 2, display this data <?php $db = &JFactory::getDBO(); $id = JRequest::getVar('id'); if ( $id ) { if ( JRequest::getVar('view') == 'section' ) { $sectionid = $id; } elseif ( JRequest::getVar('view') == 'category' ) { $query = 'SELECT section FROM #__categories WHERE id = ' . (int) $id; $db->setQuery($query, 0, 1); $sectionid = $db->loadResult(); } elseif ( JRequest::getVar('view') == 'article' ) { $query = 'SELECT sectionid FROM #__content WHERE id = ' . (int) $id; $db->setQuery($query, 0, 1); $sectionid = $db->loadResult(); } } else { $sectionid = ''; } if ($sectionid != '' && $sectionid == 2) { ?> Code for Section #2 goes here <?php } elseif ($sectionid != '' && $sectionid == 3) { ?> Code for Section #3 goes here <?php } ?>
URL: http://forum.joomla.org/viewtopic.php?f=469&t=336451