简体   繁体   中英

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. 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. i got rid of the separate area, and now want to make bglogo a link. 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)

<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. (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. What you need to do is create some css that will apply only to the link within the div with the class of 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%; and height: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%;}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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