Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#649 2010-03-04 10:00:11

jpdupont
Member
Registered: 2004-10-01
Posts: 752

Re: smd_gallery: super-flexible gallery generator

Stef,

any chance to get the “directory” filter working ?

Actually, on my host, I get this working :

directory="/home/www/3370847b68efbfb60754cc52abf91b35/users/multimedia/web/internat/interface/"

but this give no output :

directory="/images/interface/"

or

directory ="http://www.mysite.be/images/interface/" 

On an other hand, if txp debug is on, I get many thumnails errors.

Offline

#650 2010-03-11 01:10:31

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: smd_gallery: super-flexible gallery generator

jpdupont wrote:

any chance to get the “directory” filter working ?

Short answer is I don’t know, unfortunately. It worked in my rudimentary testing but my host has no support for opening URLs as files, so I couldn’t test that bit. I suppose I could try it in XAMPP and see if I can get it working. Will see what I can do.

In the meantime, here’s v0.6 to play with. The major change is that we can hopefully (finally) say goodbye to the problems with trying to pull out image IDs of uncategorised images. I completely ditched the SQL join and settled on a lazier, more direct (and more robust) approach. Shouldn’t break anything (apart from the fact that your image lists will actually be what you expect now!)

Also added the ability to specify ranges of numbers in countform, e.g. countform="3-7:my_form" would call my_form when the 3rd thru 7th (inclusive) images were encountered.

Finally, a new attribute grouplimit was added that allows you to limit the number of images shown in each group (e.g. in each category). Here’s how the limits differ:

  • maxlimit is a hard limit of records pulled from the database
  • limit affects the number of images displayed per page in a multi-page gallery
  • thumblimit only shows the given number of {object} tags at each onchange before rendering the remainder of the links as empty anchors
  • grouplimit only allows you to navigate/see this many images in each onchange group (see example 12 in the help)

As always, let me know if this version gives your galleries the horn or not.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#651 2010-03-16 21:23:37

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

Hello Stef and first thank you very much for your menagerie…
Can’t get my head around this problem: struggling with smd_gallery and I would like to output a Gallery of thumbs including pagination on a txp default home page, retrieving the thumbs from all articles in a single section… I’m not using image categories and all my thumbs are pulled directly from an article_custom call, such as:

<txp:article_custom section="thumbs" limit="10">
<txp:upm_article_image>
<txp:smd_gallery form="output_my_thumbs" limit="1" pageform="do_some_pagination"/>
</txp:upm_article_image>
</txp:article_custom>

This is actually working.
Trouble comes in when I’m trying to paginate this… It treats every article call as a single gallery and tries to paginate on each item, throwing in this case the pagination 10 times, on each image… :uO… Even the collate=“1” couldn’t solve the issue…

Can I achieve this with your plugin: paginate thumbs collected from all articles in a section ?

Thanks !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#652 2010-03-16 22:23:30

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: smd_gallery: super-flexible gallery generator

hablablow wrote:

retrieving the thumbs from all articles in a single section…

Crikey, you’re right: that code definitely won’t work! You’ll be calling smd_gallery for each article in your article_custom list so you will end up with a pagination set for each article.

What you need to do here is be clever and do things in two phases. Assuming your image IDs are in the article_image field in each article you could perhaps build up a definitive list of all of the IDs first. Untested, but something like this:

<txp:article_custom section="thumbs" limit="10">
<txp:if_variable name="thumblist" value="">
<txp:variable name="thumblist"><txp:upm_article_image /></txp:variable>
<txp:else />
<txp:variable name="thumblist" value='<txp:variable name="thumblist" />, <txp:upm_article_image />' />
</txp:if_variable>
</txp:article_custom>

(bear in mind I don’t know how to use upm_image so you’ll have to fix that bit to make it right according to Mary’s docs)

What that should do is append the article image info from each article to a txp:variable. First time round (when the variable doesn’t exist) it just sets up the variable. Every other time it sets the variable to the current value of the variable plus a comma and then the contents of the article image field. You may have to remove the value="" from the if_variable; you might only need to check if the variable exists first and not test its actual value.

The end result is a comma-separated list of article image IDs… I think you can see where this is going! Add this after the block of code above and see what happens:

<txp:smd_gallery id="?thumblist" form="output_my_thumbs" pageform="do_some_pagination" />

The other alternative is smd_query to do a similar job. Something like this:

<txp:variable name="thumblist"><txp:smd_query query="SELECT article_image FROM textpattern WHERE section='thumbs' ORDER BY Posted desc LIMIT 10" break=", ">
{article_image}
</txp:smd_query></txp:variable>

And then put the same smd_gallery tag after that. Or embed the smd_query directly inside the id attribute of smd_gallery.

See how you get on with those nuggets and let us know if they work.

Last edited by Bloke (2010-03-16 22:24:10)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#653 2010-03-17 08:41:27

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

Thanks very much Stef… I’ll surely let you know how things go…
Cheese !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#654 2010-03-17 19:53:23

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

Stef…
This is kind of almost working except it throws a wrong, different image order than the default article order fired by the previous article_custom call… Even sorted with
sort="date asc"
But now that I have a single pagination and different thumbs, a huge leap compared to where I was yesterday, another rotten nugget shows up…
I have also to get the permanent link to the article containing each image, title and article category along with the title…
Tried to wrap one of these in a variable, same as you did… Guess: I have all titles showing up at once for each image…
Is there a way to parse the result of the containing article title variable properly…
I’m lost here: image order, article permanent links, category link…


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#655 2010-03-17 20:22:56

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: smd_gallery: super-flexible gallery generator

hablablow wrote:

it throws a wrong, different image order than the default article order fired by the previous article_custom call

Does sort="fixed" in the smd_gallery tag render the images in the order you expect?

I have also to get the permanent link to the article containing each image, title and article category along with the title…

Now that’s a lot more complicated! Perhaps PHP to the rescue? At the start or end of your article_custom that sets up the txp:variables, add this:

<txp:php>
   global $article_info;
   $article_info[upm_article_image(array())] = array(
         'id' => article_id(array()),
         'title' => title(array()),
         'category' => category1(array()),
      );
</txp:php>

So that sets up an array indexed by article_image ID that we can get at later. Inside the array it stores the (article) id, title and category1 of the current article. If you want to grab other stuff, just add rows; each TXP tag has an equivalently-named function. If you need to get the category title, for example, you’ll need to issue category1(array('title' => '1')).

Then, inside your smd_gallery form you’ll need to get the relevant info from the array at the position dictated by the current thumbnail {id}. Like this:

<txp:php>
   global $article_info;
   $href = permlink(array('id' => $article_info[{id}]['id']));
   echo '<a href="' . $href . '">' . $article_info[{id}]['title'] . '</a>';
   echo 'Category1: ' . $article_info[{id}]['category'];
</txp:php>

Not sure if that’ll work, but it might.

Last edited by Bloke (2010-03-17 20:24:20)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#656 2010-03-17 20:33:05

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

Position=“fixed” worked super, same output as would the article_custom do…
As for the rest I’ll test that after some Spaghetti s… Real life knocking at my stomach right now…
If the above works, it rocks !
Thanks !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#657 2010-03-18 13:03:01

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

And it’s working Stef !
Just had to call upm_img_id instead of upm_article_img

Just some minor tweaks and some remarks concerning your plugin…

Remarks, related to my case, if you don’t mind…
I’m close to a 100% flexibility to wrap the pagination but I ran into this specific case… Once I have declared a global thumbnail wrapper, in a ul for example which is the best semantic way to go in most cases, I don’t have any other choice than to wrap the pagination in a li, adding a class to target the pagination wrapper could also be useful… So I end up with a weird list mixing tools with data… It would be cool not to necessary wrap the pagination above or below or both, although in this last case I didn’t get it to work properly, but anywhere…

Minor tweaks…
Both article and category links are linking to the same default url: /section/title whereas they should link to these two different url schemes: /section/category and /section/category/title… I thought this might come from the fact that I’m calling the upm_img_id and not the upm_article_img anymore so I tryed to build another global variable $article_info2 just for the category link and call it in the second snippet… I wasn’t surprised that it wouldn’t work… Is there a way I can just build the url myself in the form of ?s/category/title and ?s/category just by retrieving the respective names form the array…

If I have more than one image id in the image field… Pshht that image won’t show up… :8

Here’s my code:

<txp:php>
 global $article_info;
    $article_info[upm_img_id(array())] = array(
          'id' => article_id(array()),
          'title' => title(array()),
          'category' => category1(array()),
      );
  </txp:php>

Arggghhh !


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#658 2010-03-18 16:05:59

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,454
Website GitHub

Re: smd_gallery: super-flexible gallery generator

hablablow wrote:

And it’s working Stef !

Good show.

adding a class to target the pagination wrapper could also be useful…

Not sure I understand, sorry. Do the smd_gallery attributes navwraptag, navbreak and navclass not serve this purpose?

Is there a way I can just build the url myself

Yes, if the values are in the array you can use them in your smd_gallery form. I used the permlink tag for convenience but you can create them manually if you prefer. Just add the article items you want to the array and then use $article_info[{id}]['name_of_item'] to read it back and put it inside any HTML markup you like (an anchor tag in your case). If you need to distinguish between whether you are viewing an article or a category listing you’ll have to post some more page template code if you’re stuck so I can see what you’re trying to do.

If I have more than one image id in the image field… Pshht that image won’t show up… :8

Isn’t that a limitation of upm_img_id? (I don’t know, just asking the question). Perhaps it only returns the first ID in the list whereas upm_article_image might return the entire field contents? As long as whatever tool you use to read the article_image field returns it as a comma-separated list exactly as you have typed it into the article field, the code I posted should (ummm, I think) show all images. Though — on second thoughts — it might overwrite the images and only show the latest one it finds. I’d have to check but I don’t have time now.

Last edited by Bloke (2010-03-18 16:07:27)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#659 2010-03-18 22:32:12

hablablow
Member
From: Paris
Registered: 2004-12-13
Posts: 309
Website

Re: smd_gallery: super-flexible gallery generator

Got my urls working Stef with:
echo '<a href="' . $article_info[{id}]['section'] . '/' . $article_info[{id}]['category'] . '/' . $article_info[{id}]['title'] . '">' . $article_info[{id}]['title'] . '</a>';
So everything is working good except that special case when there are multiple images in one article… Tried various approach using Mary’s tags… No luck… There’s a <txp:upm_if_article_image_list /> tag… I tried to wrap it inside the article_custom call but it always evaluates to false !
In fact I would like just the first image to be returned, the other listed images in the same category don’t need to show up…


_
_I plant seeds for future visions. Farmer of your eyes. Subliminal engineer of your minds. eion founder__

Hablablow + Webdesignofficina

Offline

#660 2010-04-02 16:51:11

jan
Member
From: Utrecht, The Netherlands
Registered: 2006-08-31
Posts: 71
Website

Re: smd_gallery: super-flexible gallery generator

Stef, is it possible to display just ‘the latest album’?
I know it’s possible to sort on date, but would it then be possible to stay within that 1 category the newest image belongs to?

Thanks in advance, and once again I really enjoy playing around with one of your plugins :)

Last edited by jan (2010-04-02 16:51:33)


Kensington TXP powered rock

Offline

Board footer

Powered by FluxBB