Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-11-28 17:32:56

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 118
Website

Question regarding linked image thumbnails

I am outputing a list of articles on the article listing context, each article is a gallery (only 12 images shown), with a title and a description. On the single article page, I am outputting the gallery in it’s entirety (all images shown).

What is strange to me, are the links that TXP is generating for the thumbnails, they are somehting like: http://site.com/gallery/?c=category-name&context=image&p=16.

What I’d like to know is how do I make a template for the final (big) image, once the thumbnail is clicked? Am I supposed to use the if_category conditional? That seems weird for some reason.

I have a section named “gallery” using a page template “gallery”, and within it I have:

<txp:if_article_list>

        <div class="galleryList col holder">

          <h1>Foto Galerija</h1>
          <txp:article section='<txp:section />' limit="999">
          <div class="gallery">
            <div class="col cs-6 first aboutGallery">
	      <h2><a href="<txp:permlink />"><txp:title /></a></h2>
	      <txp:body />
              <p><a href="<txp:permlink />" class="cta">Pogledaj galeriju</a>
            </div>
            <div class="col cs-6 preview">
            <txp:images category='<txp:custom_field name="naziv_galerije" />' limit="12" thumbnail="1" wraptag="" class="" break="" />
            </div>
          </div>
          </txp:article>

          </div> <!-- .galleryList -->

<txp:else />

          <div class="article col holder">

            <txp:article>

            <h1><txp:title /></h1>

            <txp:images category='<txp:custom_field name="naziv_galerije" />' limit="12" thumbnail="1" wraptag="ul" class="images" break="li" />

            <div class="col cs-8 first comments">
              <txp:output_form form="comments-block" />
            </div>

            <div class="col cs-4 aboutGallery">
              <txp:body />
              <p><a href="<txp:site_url />galerija-foto/">Pogledaj ostale galerije</a></p>
            </div>

            </txp:article>

          </div> <!-- .article -->

</txp:if_article_list>

Offline

#2 2011-11-28 22:27:46

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 5,001
Website GitHub

Re: Question regarding linked image thumbnails

Hi Dragan,

the links are correct in that you are outputting an image category (it says &context=image) and the p=123 urlvars are used by txp:image_display to display the large image but you don’t have that tag anywhere so it won’t show.

For the individual image, two options come to mind:

  1. Use txp:image_display as a placeholder for the main image. I think it doesn’t output anything if there is no p= urlvar, but if you need more control or have surrounded markup, see note below.
  2. Use txp:images as a container tag with your own markup, e.g. for a lightbox.

Note: If you need to trap if there is/not a single image selected, you could use adi_gps to test for the presence of the p= urlvar, or alternatively you might be lucky with <txp:variable name="is_individual_image"><txp:page_url type="p" /></txp:variable><txp:if_variable name="is_individual_image" value=""><txp:else /><div id="photo_frame"><txp:image_display /></div></txp:if_variable> if page_url also works with p (it’s not documented but might work…).

BTW: a few other bits and pieces I spotted:

  • txp:article can’t take the section attribute, only txp:article_custom. You can use txp:article without any section as it will always pick up the current context.
  • the link in the article_list case was missing the trailing </p>.

TXP Builders – finely-crafted code, design and txp

Offline

#3 2011-11-29 10:45:35

draganbabic
Member
From: Novi Sad, Serbia
Registered: 2006-09-27
Posts: 118
Website

Re: Question regarding linked image thumbnails

Hi Jakob, and thanks for the reply.

You method certainly worked, but I found that I was lacking some controls for the individual image view, so I implemented a lightbox and called it a day.

My TXP foo is certainly low, since I haven’t used it in a long time (no projects of this kind to flex my muscles), but it was sure fun diving in again and reminding myself why it’s the best CMS out there.

Offline

Board footer

Powered by FluxBB