WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
Alex, how are image tags stored/used in NextGen? (9 posts)

  1. Jim R
    Member
    Posted 2 years ago #

    I can Tag each photo, which can be done in the NextGen admin panel. How are those Tags stored in the database? (Are they stored in the database?)

    How are they referred to in PHP code?

    What I'm trying to do is link post_tags from my Posts to my ngg_tags, so when you go to an Post Archive page (which for me are mostly basketball players), you see the images tagged with that person's name.

    Example:
    http://hoosierhoopsreport.com/tag/Jeremy-Hollowell/

    Everything above the line is my code. The bio information is taken from a datatable that I create and maintain. The picture is linked automatic to a NextGen gallery by making sure the image's file name matches the player's name.

    From there, I have photos taken during games, and each photo might have two or three players tagged in them. I want to match those photos to each player, and I can't locate the image in my database.

    Using the player I linked above, I know his
    term_id = 517
    term_taxonomy_id = 1200 where taxonomy = ngg_tag

    But in the ngg_ tables, I can't find 1200 anywhere, nor can I find anything that would link Jeremy Hollowell to any tags I create.

  2. Jim R
    Member
    Posted 2 years ago #

    To clarify, I'm trying to add Tagged images to Post Archive pages, not Posts.

  3. Alex Rabe
    Member
    Posted 2 years ago #

    Of course there are stored in the WordPress taxonomy database: In wp_term the "tag" is linked with a "term_id" and in wp_term_relationships the object_id <-> term_id are linked, therefore the object_id is in my case the picture id.

    In tags.php look for the function "find_images_for_tags", it will pull out images based on a tag

  4. Jim R
    Member
    Posted 2 years ago #

    Cool. I forgot to check the relationship table. I'll take a look at it and hopefully make sense of it.

  5. Jim R
    Member
    Posted 2 years ago #

    Ok...not making much of it. I gave it a shot on my own before I checked it out. I know little about Joins, and I know little about mysql_fetch_assoc.

    To start I have called the tag_id I'm working with this:

    $wp_tagID = get_query_var('tag_id');

    $qImage = 'SELECT * FROM wp_ngg_pictures AS np
    LEFT JOIN wp_term_relationships AS tr ON np.pid = tr.object_id
    LEFT JOIN wp_term_taxonomy_id AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id
    LEFT JOIN wp_terms AS t ON tt.term_id = t.term_id
    WHERE tt.taxonomy = ngg_tag
    AND t.term_id = "$wp_tagID"
    ';

    $pImage = mysql_query($qImage);
    while($images = mysql_fetch_assoc($pImage)) {

    echo $images;
    }

    I'm getting this error:

    Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/jwrbloom/public_html/resources/wp-playerProfile.php on line 109

    In my mind I'm trying to get all the information from the wp_ngg_pictures table.

    From there I'm trying to match the pid with the object_id in the wp_terms_relationships table. (128,140,147)

    I'm taking the term_taxonomy_id associated with those images (1200) and trying to match it with the term_id (517) in the wp_term_taxonomy table where the taxonomy = ngg_tags.

    Then somehow, I'm trying to match the term_id to the tag_id I brought to the page in the very beginning.

  6. Alex Rabe
    Member
    Posted 2 years ago #

    did you try to use just the function find_images_for_tags() for your purpose, maybe it's easier this way ?

  7. Jim R
    Member
    Posted 2 years ago #

    How would I go about doing that? It would need to have a variable, like find_images_for_tags($nameFirst . ' ' . $nameLast)

  8. Alex Rabe
    Member
    Posted 2 years ago #

    if you know the tag_id , then you can search for the images or did I missed something ?

  9. Jim R
    Member
    Posted 2 years ago #

    Where are you intending for me to use this?

    I'm hard coding this in the template PHP file that via an Include. Are you saying it would look like:

    find_images_for_tags($wp_tagID, mode = "ASC"), and the number included would be regulated by the Dashboard?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.