SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Jun 2009
    Posts
    317
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Creating a link via shortcode function

    Hi,

    I have a plugin which doesn't do what I need it to so I have to edit the code. It's an image based plugin which I need to add links in the thumbnail descriptions. I have managed to edit the plugin to display whatever descriptions. However, I need to create a clickable link which isn't yet possible.


    PHP Code:
    <p align="left" style="margin-left:0px;">
    <?php echo $image->alttext ?>

    <?php echo $image->ngg_custom_fields["img_url"?>
    </p>
    I added the ngg_custom_fields["img_url"] bit which displayed the URL that I have added but can I change the code somehow to make it clickable?

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    You go back to basic HTML and create a test link in longhand on the page.

    eg
    Code:
    <p align="left" style="margin-left:0px;"> 
    <a href="/myimages/test.jpg" alt="My test image">test.jpg</a>
    </p>
    (change the values so that the link works, linking to a test image which does exist)

    You get that working so the path is clearly correct and clicking the link takes you to the image (in this case).

    You then replace the variables with PHP code which generates the correctly formed HTML

    eg
    PHP Code:
    <p align="left" style="margin-left:0px;"> 
    <a href="/myimages/<?php echo $image->ngg_custom_fields["img_url"?>
       alt="<?php echo $image->alttext ?>">
        <?php echo $image->ngg_custom_fields["img_url"?>
    </a>
    </p>
    I added some line ends in order that it displays correctly on this forum, that's all.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •