简体   繁体   English

在Joomla模板中使用PHP创建链接

[英]creating a link with PHP in a Joomla template

i'm trying to modify a Joomla template to create a link out of a defined 'div' on the index.php page and am not having any luck. 我正在尝试修改Joomla模板,以在index.php页面上从定义的“ div”创建链接,并且没有任何运气。 in the original source, there was an an object, 'bglogo' which is a static .jpg, and a separate area within it that contained the link. 在原始来源中,有一个对象'bglogo',它是一个静态.jpg,并且在其中包含链接的单独区域。 i got rid of the separate area, and now want to make bglogo a link. 我摆脱了单独的区域,现在想使bglogo成为链接。 i can't figure out how to do this, the php code is below and the webpage is tagalong.in (bglogo being the image in the top right corner of a name tag) 我不知道该怎么做,下面是php代码,网页是tagalong.in(bglogo是名称标签右上角的图像)

<div id="entries">
    <jdoc:include type="modules" name="content-top-a" style="xhtml" />
    <jdoc:include type="message" />
    <jdoc:include type="component" />
    <div class="clr"></div>
    <jdoc:include type="modules" name="content-bottom-a" style="xhtml" />
</div>

<div id="sidebar">

    <!-- logo about etc here -->
    <div class="bglogo">
        <a href= "http:www.meetup.com/tag-along" > </a>
    </div>

    <!-- menu -->
    <?php if( $this->countModules('sidebar-a') ) { ?>
    <div id="sidebartop">
        <jdoc:include type="modules" name="sidebar-a" style="xhtml" />
    </div>
    <?php } ?>

    <?php if( $this->countModules('sidebar-b') ) { ?>
    <div id="sidebarright">
        <jdoc:include type="modules" name="sidebar-b" style="xhtml" />
    </div>
    <?php } ?>


    <div id="sidebarleft">
        <?php if( $this->countModules('sidebar-c') ) { ?>
        <jdoc:include type="modules" name="sidebar-c" style="xhtml" />
        <?php } ?>
        <?php echo '<h3>Copyright</h3>'.$copyright . $warningerrorx; ?>
    </div>


</div>

我实际上不太确定您在说什么,但是如果您希望图像显示在链接中,则可以这样操作:

    <a href="http://www.meetup.com/tag-along"><img src="your/path/blogo.jpg"/></a>

Okay I see where you are going. 好吧,我知道你要去哪里。

You will need to add http the colon and two forward slashes to the beginning of the link. 您将需要在链接的开头添加http冒号和两个正斜杠。 (had to describe it that way as they get stripped - as per my original comment). (必须以这种方式描述,因为它们被剥夺了-根据我的原始评论)。

The link is present already - but has nothing inside of it - because the image is a background image on the div. 该链接已经存在-但其中没有任何内容-因为该图片是div上的背景图片。 What you need to do is create some css that will apply only to the link within the div with the class of bglogo. 您需要做的是创建一些CSS,这些CSS仅适用于div中具有bglogo类的链接。 This should then be given a width and height so it overlays your background image. 然后,应为其指定宽度和高度,以使其覆盖您的背景图像。

Because the parent bglogo div is already the right height and width I'd suggest width: 100%; 因为父级bglogo div已经是正确的高度和宽度,所以我建议width:100%; and height:100%. 和高度:100%。 Be aware that links are generally inline elements and don't normally take a height or width. 请注意,链接通常是内联元素,通常不会采用高度或宽度。 So we must also tell the anchor (link) to behave like a block level element. 因此,我们还必须告诉锚点(链接)的行为类似于块级元素。

All together that gives us: 所有这些使我们:

.bglogo a{display:block; width: 100%; height:100%;}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM