Vizionz Posted August 2, 2010 Share Posted August 2, 2010 <?php if ($this->item->type == 'demo') : ?> <div class="demo"><?php echo $this->renderer->render('item.demo.full', array('view' => $this, 'item' => $this->item)); ?></div> <?php else: ?> <div class="item"><?php echo $this->renderer->render('item.full', array('view' => $this, 'item' => $this->item)); ?></div><?php endif; ?> now how would i add another class to show <?php if ($this->item->type == 'demo1') : ?> <div class="demo1"><?php echo $this->renderer->render('item.demo1.full', array('view' => $this, 'item' => $this->item)); ?></div> <?php else: ?> <div class="item"><?php echo $this->renderer->render('item.full', array('view' => $this, 'item' => $this->item)); ?></div><?php endif; ?> how would i combine them into a workking code. so it would check first to see if Demo and demo 1 exist and if not it would dispaly the item. Link to comment https://forums.phpfreaks.com/topic/209568-does-this-code-make-sence-to-you-and-if-so/ Share on other sites More sharing options...
JonnoTheDev Posted August 2, 2010 Share Posted August 2, 2010 <?php switch($this->item->type) { case "demo": echo "<div class=\"demo\">".$this->renderer->render('item.demo.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; case "demo1": echo "<div class=\"demo1\">".$this->renderer->render('item.demo1.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; default: echo "<div class=\"item\">".$this->renderer->render('item.full', array('view' => $this, 'item' => $this->item))."</div>\n"; break; } ?> Link to comment https://forums.phpfreaks.com/topic/209568-does-this-code-make-sence-to-you-and-if-so/#findComment-1094074 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.