WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Custom Fields
WHERE do I put the code for custom fields in an album? (17 posts)

  1. crashprojects
    Member
    Posted 2 years ago #

    I personally am using a nextgen gallery to manage an inventory as there really is no proper inventory manager for wordpress that doesn't look like crap. I thought these custom fields would be the answer to my prayers as I could post multiple pictures of an item in in a relatively aesthetically pleasing manner AND create the fields appropriate for the kind of items I'm managing but to no avail, as of yet.

    I have put this:

    <?php echo $image->ngg_custom_fields["Your Field Name Here"]; ?> in a bunch of different places yet have not gotten it to work.

    I'm using 1 gallery with a separate gallery for each item. The custom fields will be the same for each item.

    I'm not going to go as far as to say "half baked" (as was said in a previous thread) but it would be infinitely helpful for someone to say

    Find this file___.
    Put this code___between___and___.

    Etc. etc. At this point I apparently don't even know what I'm looking for.

    Thanks.

    http://wordpress.org/extend/plugins/nextgen-gallery-custom-fields/

  2. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    A gallery within a gallery!? WE NEED TO GO DEEPER... Galleryception.

    In all seriousness, you put the tag where you want the custom field to show. The <?php echo $image->ngg_custom_fields["Your Field Name Here"]; ?> tag will only work inside the loop of an NGG template. So if you are displaying the gallery with the NGG short code [nggallery id=x] you can put that tag anywhere from the start <?php foreach ( $images as $image ) : ?> to the <?php endforeach; ?> in the /view/gallery.php template.

    If you want to show a field outside of the loop, you can call the tag <?php echo nggcf_get_field($pid, 'Your Field Name Here'); ?> ANYWHERE you want (obviously where $pid equals your image id).

    I realise the docs aren't great. But if you are building a website, you should know your way around a code base well enough to figure it out. One day I will get around to improving the docs. But right now, there's more cool code to write.

  3. crashprojects
    Member
    Posted 2 years ago #

    Thanks for replying Shauno. Appreciated!

  4. mamouneyya
    Member
    Posted 2 years ago #

    But, any change that will be made directly to a NGG file will be overwritten after every update for NGG plugin, right? If so, is there a better way to keep the changes safe?

    A gallery within a gallery!? WE NEED TO GO DEEPER... Galleryception.

    LOOOL :D

  5. mamouneyya
    Member
    Posted 2 years ago #

    shauno, I have another question when you have some time: How can I add the custom field values inside the pop-up windows of gallery images?

    Thanks.

  6. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    The templates are overwritten when you update NGG. That's just a default behaviour for WP plugins.
    Check out this link: http://nextgen-gallery.com/templates/
    It describes moving your templates into your theme. I haven't personally tried it, but it sounds sweet :)

    Adding the custom fields to the popup has been asked before. The problem is that NGG uses the Thickbox javascript that is included by default in WP. The markup for the popup is generated on the fly by the javascript, so injecting custom fields there will be a nightmare. Its on the list of things to look at though!

  7. Ramzii
    Member
    Posted 2 years ago #

    Ok, thanks for pointing me to this thread Shauno.

    Ive been googling some and think im on the right track.

    If the other members can have a looksie too im sure together we will find an awesome solution! Hooray, lol.

    What we are trying to achieve, has been achieved here:
    208.43.238.130/~mrmead/index.php?/portfolio/

    Im just not sure if its been done WITH the nggallery.
    Im just sure its thickbox that site is using.

    The site owner talks here: http://www.indexhibit.org/forum/thread/10029/

    He tells us to look here:
    http://www.indexhibit.org/forum/thread/1039/

    Now im a tad in over my head, so your take on this.. much obliged!

  8. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    As I said above, it's something that's on my list to look into.
    Last time I looked, thickbox did not expose any public events, so my guess is it will require hacking of the core thickbox files, which is why I have been hesitant in doing it.

    One day... :)

  9. mamouneyya
    Member
    Posted 2 years ago #

    Actually, I see that NGG offers many scripts to choose from, not only Thickbox:
    http://grab.by/b7ce
    so maybe you can hook into another library we can use?

  10. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    Ok, I had a quick look at this again when one of the servers went down at my office (shh, dont tell my boss).

    You can just put the custom fields in the title attribute of the anchor as a quick hack.

    title="<?php echo $image->description ?><ul><li><?php echo $image->ngg_custom_fields["My field 1"]; ?></li><li><?php echo $image->ngg_custom_fields["My field 2"]; ?></li></ul>"

    That worked with thickbox and the shutter effect. You may need to fiddle with your style sheet, as the popups weren't really built with mark-up in mind I guess

  11. mamouneyya
    Member
    Posted 2 years ago #

    Sorry for the delayed feedback! Well, this works good except the long ugly ballon on mouse hover, which absolutely can be lived with..

    Thanks for your time, shauno!

  12. Ramzii
    Member
    Posted 2 years ago #

    Im not finding this the ideal solution, how about alternatives?

    Can we help in some way or another?

  13. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    It was a hack idea, and was never perfect. Just something I came up with in 15min free time.
    I would need to look at the alternative effects, and what event hooks they have. Essentially, I would be looking for an 'onOpen' (or something like that), and then injecting the custom fields into the correct place in the popup markup.

    I will try find the time to look at it in more detail soon.

  14. Ramzii
    Member
    Posted 2 years ago #

    Thanks Shaun, I will also keep looking into this website and how its been achieved:

    http://208.43.238.130/~mrmead/index.php?/portfolio/

  15. shauno
    Member
    Plugin Author

    Posted 2 years ago #

    That site does not use WP (and thus not NGG). All they have done is used line breaks in the description. If you hover over the images you actually see the <br /> in the tool tip text.

  16. Ramzii
    Member
    Posted 2 years ago #

    Ok, ive found a relatively easy way... its KINDA messy IF you have the title hover effect on each thumb enable. So i suggest you use this only when youve disabled it.

    On line 40 of the gallery.php I altered everything like so:

    <div id="ngg-image-<?php echo $image->pid ?>" class="ngg-gallery-thumbnail-box" <?php echo $image->style ?> >
    		<div class="ngg-gallery-thumbnail" >
    			<a href="<?php echo $image->imageURL ?>" title="" <?php echo $image->thumbcode ?> >
    				<?php if ( !$image->hidden ) { ?>
    				<img title="" alt="<?php echo $image->description ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
    				<?php } ?>
    			</a>
    		</div>
    	</div>

    This way the titles wont show up anywhere, BUT underneath the picture (when large)

    I also switched the alt - tags and descriptions place. Found this easer to work with inside the gallery management.

    All you have to do now to display the caption in a list is type the following in the description area of the picture:

    <li>Yay</li>
    <li>this  </li>
    <li>actually</li>
    <li>works </li>

    :D

    *sidenote: i havent actually installed this plugin, used this on a pure NGGALLERY plugin, lol

    Hope someone finds use for this, more slick ways of achieving a listed caption are still very welcome!

  17. Toshi Yoshida
    Member
    Posted 2 years ago #

    Ramzii, If you want to get rid the of messy hover/s then you need to use alttext instead of description or caption in your code.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic