• Resolved dizzy100

    (@dizzy100)


    Having recently upgraded my work in progress blog to 2.3 i looked around for a replacement for Ultimate Tag Warrior to display inline embedded tags as links.

    I’m working on a movie website so each movie will list actors starring with a link created alongside their name to their tag (allowing members to drill down to all articles about them).

    UTW worked well and i found a replacement by christine entitled Embedded Tag Thing which i was very excited about.

    However its not all rosy ?? First there is a bug that doesn’t allow space within the tags. So tag]foo[/tag] will function as it should. However [tag]foo bar[/tag] will not display at all and even removes foo bar from the post body.

    The second, and much much more major issue i’ve encountered is that each tag generates 1 query. Add 17 tags within a post (very likely with actors etc) and you have 17 extra queries generated per page which is going to be quite some load.

    I contacted the author on both counts but have failed to see a response ?? So i’m not confident of a fix any time soon. I’ve also looked at the code and frankly can’t see why its generating so many queries or the bug within the white space.

    Now, falling short of hand coding every tag link with full url and adding to the database manually is there a way around this ?

    Simple tags looks promising but currently doesn’t generate embedded links ??

    Any help appreciated.

Viewing 1 replies (of 1 total)
  • Thread Starter dizzy100

    (@dizzy100)

    Just to say i’ve solved this issue with a workaround. I’ve written a function that goes through my custom fields looking for delimiters I’ve set. I pass the function the contents of that custom field and then the function hand code the url as its output. It works and works well.

    Heres the solution

    The custom field has something similar to the following contents within

    John Wayne … George Washington McLintock
    Maureen O’Hara … Katherine McLintock
    Yvonne de Carlo … Louise Warren
    Patrick Wayne … Devlin Warren
    Stefanie Powers … Becky McLintock
    Jake Kruschen … Jake Birnbaum
    Chill Wills … Drago
    Jerry Van Dyke … Matt Douglas, Jr.
    Edgar Buchanan … Bunny Dull
    Bruce Cabot … Ben Sage
    Perry Lopez … Davey Elk
    Michael Pate … Puma
    Strother Martin … Agard
    Gordon Jones … Matt Douglas
    Robert Lowery … Gov. Cuthbert H. Humphreys
    Leo Gordon … Jones

    My call to my routine –

    <p style="float: left;  background:#470101;"><?php actors(get_post_meta($post->ID, "Actors", $single = true)); ?>

    And the routine itself

    function actors ($test) {
    $array = explode("\r\n", $test);
    
    foreach ($array as $value) {
        $actor=substr($value, 0, strpos($value, " ... "));
        $tag = str_replace(" ", "-", $actor );
        $character = strstr ($value, "...");
        echo '<a href="../tag/' . $tag . '">' . $actor . '</a> ' . $character . '';
        }
        unset ($value);
    }

    The delimiter is and the function will go through my custom field and separate actors into variables and then split those variables up to allow for direct linking to tags (actors name as a hyperlink and actors character next to it). The routine removes whitespace and inserts – instead to allow the tags to work as expected.

    It doesn’t insert the tags into the database as yet as I haven’t figured a way to pass the post->ID variable to my function so i can modify christines routine to insert these into the database automatically, but i’ll try working on that later.

    This uses absolutely no queries whatsoever so is a crude but effective solution to the issues i faced.

    Hope that helps somebody else.

Viewing 1 replies (of 1 total)
  • The topic ‘Embedded Tag Thing’ is closed to new replies.