Support » Plugins » [Plugin: NextGEN Custom Fields] Link in custom field repeating

  • Hi there

    Thank your for the plugin. It is great. I am just having a tiny problem where the information in the custom field is repeating several times in the code – looks fine on the surface but when I check the html code the external link I have put into the custom field has duplicated around four times.

    I have used the plugin to make the title of the main image link to an external website (website portfolio) in NextGEN. I am using the gallery-carousel.php. This is the code I am using:

    <div class="ngg-galleryoverview">
    	<div class="pic">
    		<img title="<?php echo $current->alttext ?>"
    	 	alt="<?php echo $current->alttext ?>"
    	 	src="<?php echo $current->url; ?>" />
    	<div class="albumtitle">
    		<a href="<?php echo $current->ngg_custom_fields["Link"]; ?>" > <?php echo $current->alttext ?>

    I tried using $image->ngg_custom_fields but that didn’t work at all. The strange thing is that it is repeating in the thumbnail list and the above code is outside the thumbnail code. Below is the entire code for the page thumbnail. My site is not live yet so I am unable to provide a link:

    Template Page for the gallery carousel
    Follow variables are useable :
    	$gallery     : Contain all about the gallery
    	$images      : Contain all images, path, title
    	$pagination  : Contain the pagination content
    	$current     : Contain the selected image
    	$prev/$next  : Contain link to the next/previous gallery page
     You can check the content when you insert the tag <?php var_dump($variable) ?>
     If you would like to show the timestamp of the image ,you can use <?php echo $exif['created_timestamp'] ?>
    <?php if (!defined ('ABSPATH')) die ('No direct access allowed'); ?><?php if (!empty ($gallery)) : ?>
    <div class="ngg-galleryoverview">
    	<div class="pic">
    		<img title="<?php echo $current->alttext ?>"
    	 	alt="<?php echo $current->alttext ?>"
    	 	src="<?php echo $current->url; ?>" />
    	<div class="albumtitle">
    		<a href="<?php echo $current->ngg_custom_fields["Link"]; ?>" > <?php echo $current->alttext ?>
    	<div class="ngg-galleryoverview">
    	<ul class="ngg-gallery-list">
    		<!-- PREV LINK -->
    		<?php if ($prev) : ?>
    		<li class="ngg-prev">
    			<a class="prev" href="<?php echo $prev ?>">◄</a>
    		<?php endif; ?>
    		<!-- Thumbnail list -->
    		<?php foreach ( $images as $image ) : ?>
    		<?php if ( $image->hidden ) continue; ?>
    		<li id="ngg-image-<?php echo $image->pid ?>" class="ngg-thumbnail-list <?php if ($image->pid == $current->pid) echo 'selected' ?>" >
    			<a href="<?php echo $image->pidlink ?>" title="<?php echo $image->description ?>" >
    				<img title="<?php echo $image->alttext ?>" alt="<?php echo $image->alttext ?>" src="<?php echo $image->thumbnailURL ?>" <?php echo $image->size ?> />
    	 	<?php endforeach; ?>
    	 	<!-- NEXT LINK -->
    		<?php if ($next) : ?>
    		<li class="ngg-next">
    			<a class="next" href="<?php echo $next ?>">►</a>
    		<?php endif; ?>
    <?php endif; ?>

    I would really appreciate some help on this – several hours later and I still have no idea why it is happening.

    Thank you.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hey Calicosun

    I don’t know if the $current object runs a hook that is needed for the Custom Fields plugin to get its data.

    Maybe you can try using nggcf_get_field($current->pid, "Link") instead and see what happens.

    So replace your line with:
    <a href="<?php echo nggcf_get_field($current->pid, "Link"); ?>" > <?php echo $current->alttext ?>

    Hope that helps

    Hi there

    Thanks for your quick reply. Have tried your suggestion and have the same problem as using the $current. They both work, even the source code looks fine but the first thumb nail is not positioned properly as there is a random sitting in there that has been duplicated. When I check the html code using firebug you can see the repeated links (3x). It looks like this – not all the code, just the code that shows the duplicate links of bayhomeopathy. The first one is correct the rest have sneaked in…:

    <div class="ngg-galleryoverview">
    <div class="albumtitle">
    <a href="">
    <a href=""> </a>
    <div class="ngg-galleryoverview">
    <a href=""> </a>
    <div class="ngg-gallery-list">
    <a href=""> </a>
    <li id="ngg-image-88" class+"ngg-thumbnail-list">
    <a href=""> </a>
    <a title=" " href="/slicecreative/portfolio/other-projects/thumbs/thumb id="ngg-image-88" class="ngg-thumbnail-list"> and some other stuff</a>

    Just had a quick look at the full code you posted initially.
    Looks like you don’t close the a tag for the custom field link?

    I get a bit confused when closing a tags in this situation. I have done it like this:

    <a href="<?php echo nggcf_get_field($current->pid, "Link"); ?>" /> <?php echo $current->alttext ?>

    ie. with the />. The code I first posted just had the > …. but that seemed to validate with strict.

    Am I closing it incorrectly? breaks things.

    Thanks for looking at this by the way. I do appreciate it and know it is a pain that my site isn’t live.

    I don’t think that would can close an anchor tag like that.
    Try <a href="<?php echo nggcf_get_field($current->pid, "Link"); ?>"> <?php echo $current->alttext ?></a>

    Hi all

    I managed to hack the slideshow for use with: nggcf_get_field
    In imagerotator.php : purpose linkage for every slide picture individually…
    – a get the current pic id
    – define my field : link
    – get the field values via nggcf_get_field function
    – parse it into the xml loop… that;s it!

    Ciao Valentijn

    if (is_array ($thepictures)){
    	foreach ($thepictures as $picture) {
    		$picnr = $picture->pid;
    		$fname = "link";
    		$link = nggcf_get_field($picnr, $fname);
    		echo "		<track>\n";
    		if (!empty($picture->description))
    		echo "			<title>".strip_tags(stripslashes(html_entity_decode(nggGallery::i18n($picture->description))))."</title>\n";
    		else if (!empty($picture->alttext))
    		echo "			<title>".stripslashes(nggGallery::i18n($picture->alttext))."</title>\n";
    		echo "			<description>".$picture->filename."</description>\n";
    		echo "			<info>".$link."</info>\n";
    		echo "			<location>".$siteurl."/".$picture->path."/".$picture->filename."</location>\n";
    		echo "		</track>\n";

    Hi Shauno

    Closing as you suggested breaks the code completely, including removing the title name completely. I work with strict and closing as I did validated fine, plus the code works fine (except for the link duplicating behind the scenes). It is also how the other hrefs are closed in this file and others I have seen when enclosing a php tag so I don’t think that is why I am having the duplicated link problem – plus the links display perfectly (with the tag) when view in firebug, html.

    Hi ontwerp73
    Thanks for replying. Hmmm – not sure if your suggestion is going to work for me but thanks… first off I just want the title to have the link. I have the large image displaying on the page with the title underneath and then the thumbnails using the carousel ( nextGEN theme. Carousel doesn’t use the imagerotator.php file. There will only be some titles that need to link as the portfolio is a combination of both printed work and websites – only want a link for the website.

    Does anyone else have any suggestions as to why this might be happening? Again, apologies for not having the site live – I know this makes things harder to get help.

    Hey Calicosun
    I haven’t had a chance to look at this in more detail yet, but hopefully I will be able sometime this weekend.
    Let me know if you figure it out before then 🙂

    Thanks shauno. I do appreciate you looking into this for me.

    I have spent some more time looking into this but my knowledge of scripts and php is still developing so it is a bit like looking for a needle in a Haystack for me. I have enough knowledge now to have some idea of where to look usually but this one has got me totally stumped.

    I have noticed another problem in that all the titles have become links. I know why that is – I just need to figure out how to code the php so it displays the album title as a link if something is in the custom field and if not just the album title not as a link.

    I am hoping to have my site live by the end of the weekend so perhaps it might be easier if you wait until then – I can post when it has happened – so you can see exactly what I am talking about.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: NextGEN Custom Fields] Link in custom field repeating’ is closed to new replies.