这是我第一次使用stackoverflow,所以如果我做错了什么,我会道歉。标题说明了一切:我需要插入一个目标=" _blank" (或者将这六个链接中的两个在新窗口/选项卡中打开)到这个php echo语句中,而不删除任何php代码。第二个和第四个列表项是我尝试更改的链接。如果有帮助的话,我会使用TomatoCart。
<?php
echo '<li ' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link(FILENAME_DEFAULT, 'index'), $osC_Language->get('home')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link('http://www.acehardwaretexas.com/files/circular/index.html'), $osC_Language->get('promos')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link(FILENAME_INFO, 'articles&articles_id=1'), $osC_Language->get('services')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link('https://www.acehardware.com/acerewards'), $osC_Language->get('rewards')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link(FILENAME_INFO, 'articles&articles_id=2'), $osC_Language->get('hours')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'contact' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . osc_link_object(osc_href_link(FILENAME_INFO, 'contact'), $osC_Language->get('contact_us')) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>';
?>
答案 0 :(得分:0)
用锚标记替换了链接对象。
<?php
echo '<li ' . ($osC_Template->getGroup() == 'index' && $osC_Template->getModule() == 'index' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span><a target="_blank" href="index">home</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span><a target="_blank" href="http://www.acehardwaretexas.com/files/circular/index.html">promos</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span<a target="_blank" href="articles&articles_id=1">services</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span><a target="_blank" href="https://www.acehardware.com/acerewards">rewards</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span><a target="_blank" href="articles&articles_id=2">hours</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'contact' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span><a target="_blank" href="contact">contact_us</a><span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>';
?>
答案 1 :(得分:0)
您可以在osc_link_object函数上运行str_replace,并将<a
替换为<a target="_blank"
例如,第二个链接可能是
'<li ' . ($osC_Template->getGroup() == 'info' && $osC_Template->getModule() == 'articles' ? 'class="navVisited"' : null) . '><span class="navLeftHook"> </span>' . str_replace("<a ", "<a target='_blank' ", osc_link_object(osc_href_link('http://www.acehardwaretexas.com/files/circular/index.html'), $osC_Language->get('promos'))) . '<span class="navHoverDownHook"> </span><span class="navRightHook"> </span></li>' .