我有一个PHP elseif的代码看起来像,的Joomla 3,改变PHP否则,如果为站点链接到一些全球
<?php if ($item->getPrimaryImage()) :?>
<img src="<?php echo $item->getPrimaryImage()->getSource(); ?>" class="sprocket-lists-image" alt="" />
<?php endif; ?>
<?php echo $item->getText(); ?>
<?php if ($item->getPrimaryLink()) : ?></br>
<?php if ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=3200") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=1508") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=1840") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=2541") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/topmenu-1478/3350-2015-03-10-09-52-10") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=3426") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php elseif ($item->getPrimaryLink()->getUrl() == "index.php/component/content/article?id=3420") : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php else : ?></br>
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="modal" rel="{size: {x: 1024, y: 550}, handler:'iframe'}"><span><?php rc_e('READ_MORE'); ?></span></a>
<?php endif; ?>
<?php endif; ?>
的代码非常简单,那就是
所有elseif有一个链接开始像==“index.php ...等,,,这意味着读取按钮将打开像_parent链接没有MODAL ..
最后(案件)其他打开所有其余的林KS里面的MODAL
问题
你会发现,像开始“的index.php/.. ,,, 是有编码,以避免所有的任何方式都在elseif的情况下,链接elseif和全球化,这意味着将认识到起始链接“index.php/..? 你会发现,在随后的行动在所有的情况下,ELSEIF
<a href="<?php echo $item->getPrimaryLink()->getUrl(); ?>" class="readon"><span><?php rc_e('READ_MORE'); ?></span></a>
是一样的。
我需要一段代码,就明白了,认识的链接开始“的index.php/.. 这可能吗?
目标
我的目标是,我不想用这么许多elseif每次必须添加一个新的链接,代码会照顾它,现在每当我必须添加一个新的图像横幅,将链接到joomla网站内的文章,我必须硬编码并添加一个新的elseif像上面,,否则它会打开它的模态..
我希望其明确的eno唉,请一些帮助的原因我尝试的年龄来解决这个..
预先感谢您阅读这篇..
伊曼纽尔你治!这是eaxclty,我正在寻找,substr工作像一个魅力, – dc03kks
标记为正确的答案!! ,,非常感谢你的努力 – dc03kks
听到这一点很高兴,欢迎你! – emmanuel