WordPress.org

Ready to get started?Download WordPress

Forums

Links: Description vs. Notes (semi-urgent) (5 posts)

  1. Michael Heilemann
    Member
    Posted 10 years ago #

    So I went and noticed the addition of 'Notes' to the fields in Links. But how do I go about using them?
    See the problem is that so far I've used Description quite a bit, but since I want to do something a bit more advanced with the links system (sort of a mini content management system or something like that) the inclusion of HTML support is much needed.
    For an example of what I want to do have a look at this 'sketch' of my new design, it's the two green boxes out on the right. (Never mind the design, it's a sketch :)
    http://binarybonsai.com/images/sketch.jpg
    Ideally I would want the get_links to automatically format everything, but seeing as it's quite rigid in what it can do I'll need to format the title of the box in the notes using HTML.

  2. Mike Little
    Member
    Posted 10 years ago #

    Hi Michael,
    If you have a look in the file wp-links/links.php there is a new function get_linkobjects() .
    This function works a little like the main WP 'loop'. It returns an array of link objects you can loop through with a foreach loop, and you can refer to each of the elements of a link individually within your loop.
    So you can do something like
    <table>
    <?php
    $links = get_linkobjects(1);
    if ($links) {
    foreach ($links as $link) {
    echo <<<LINK
    <tr>
    <td rowspan="2">link_url"><img src="$link->link_image" /></td>
    <td><h2>link_url">$link->link_name</h2></td>
    <td>$link->link_notes</td>
    <tr>
    LINK;
    }
    }
    ?>
    </table>
    (I've not tried this exact example but you get the idea)
    All the available fields are documented in the file with the function.
    Hope this helps,
    Mike

  3. Michael Heilemann
    Member
    Posted 10 years ago #

    I think some formatting might've been lost here :) Could you mail it to me on eudaimic@binarybonsai.com? Thanks a lot!

  4. RowanWernham
    Member
    Posted 9 years ago #

    Did you get this working OK? I also had problems using what was posted- it seems to be missing a few characters or something. I'm not quite sharp enough with php to put it together..

    Thanks

    Rowan

  5. RowanWernham
    Member
    Posted 8 years ago #


    <?php $links = get_linkobjects(1);
    if ($links) {foreach ($links as $link) {echo <<<LINK
    <div class="memberslinkpost">
    <div class="memberslinkimagecolumn">
    link_url"><img src="$link->link_image" />
    </div>
    <div class="memberslinktextcolumn">
    <span style="color: #567F88; text-transform: lowercase; float: right; padding-right: 8px;
    ">« $link->link_description</span>
    <h2>link_url">$link->link_name
    </h2>
    <div class="memberslinktextbody">
    $link->link_notes
    </div>
    </div>
    </div>
    LINK;
    }
    }
    ?>

    This is what I have in my page now with CSS divs added in. Thought it might be useful to someone.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.