Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#676 2010-05-08 09:23:39

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: smd_gallery: super-flexible gallery generator

Hi Hope you can help!

Firstly this is one amazing plugin! I use it for all the sites I build! Don’t know what I would do without it!

However I have quite a complex site to build and I am unsure how to setup this gallery that will be very easy for them to update.

Its for a pottery website where they would like all the artists listed in alphabetical order on one page and then you click on someones name which then goes through to the artists personal page showing a description and then 6 images of that artists work.

Now I know I can do this by catagory but that wont be very easy for them to update.

Is there a way maybe the plugin can only show the images matching the alt tag name or the article name?

Or can someone suggest something easier?

Thanks SO much in advance!

Offline

#677 2010-05-10 07:25:19

miles
Member
From: Plymouth
Registered: 2008-05-22
Posts: 78
Website

Re: smd_gallery: super-flexible gallery generator

Dont worry found the best option!

Simly use <txp:smd_gallery id=”?article_image” form=“gallery” />

And put the images in the article images box seperated by commas

Offline

#678 2010-05-11 11:07:57

Hennie
Member
From: Nederland
Registered: 2009-02-06
Posts: 18
Website

Re: smd_gallery: super-flexible gallery generator

Scott, did you already figured out a hack to limit thumbnails to just one per subcategory with sublevel=“all” ?

Offline

#679 2010-05-11 11:58:53

Scott Girvan
Member
Registered: 2010-04-14
Posts: 10

Re: smd_gallery: super-flexible gallery generator

Hi Hennie,
No I haven’t. It would be great to find a solution. My gallery is filling up and I’ll need to paginate it soon.

Offline

#680 2010-05-12 22:35:23

photonomad
Member
Registered: 2005-09-10
Posts: 290
Website

Re: smd_gallery: super-flexible gallery generator

Might there be a way to output the file size (in megabytes) of the full size image in the smd_gallery form? I’d like to say: Filesize is {imgfilesize} or something like that under each thumbnail.

Offline

#681 2010-05-12 22:55:03

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

Re: smd_gallery: super-flexible gallery generator

photonomad wrote:

Might there be a way to output the file size (in megabytes) of the full size image in the smd_gallery form?

Sadly, not directly. But you can get it using a snippet of PHP like this:

<txp:smd_gallery category="some-cat">
   <txp:thumbnail id="{id}" />
   <div>Filesize is <txp:php>
         global $img_dir;
         echo round(filesize($img_dir . '/{imagedef}') / 1024 / 1024, 2);
      </txp:php> MB
   </div>
</txp:smd_gallery>

That should grab the file’s size (in Bytes) and convert it to Megabytes for you. The round() functions stops it displaying something silly like 0.002854347229MB.


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#682 2010-05-14 13:59:59

jmuspratt
Member
From: Nashville, TN
Registered: 2004-10-27
Posts: 54
Website

Re: smd_gallery: super-flexible gallery generator

First off, great plugin Stef. This thing is really amazing.

I’m wondering if it’s possible to use the plugin to hack an extra level of sub-navigation. I’m trying to make a set of artist galleries where each artist is a top-level category and has a number of sub-categories:

Image categories and subcategories:

Joe
> Joe Portfolio 1 
> Joe Portfolio 2
etc.

Mary
> Mary Portfolio 1
> Mary Portfolio 2
etc.

Ted
> Ted Portfolio 1
> Ted Portfolio 2
etc.

To make updating easier, I would really like to link these image categories to TXP articles, not sections.

So I created a section called artists, pointed it at an artists page, posted Joe, Mary, and Ted articles, and they show up fine articles show up at site.com/artists/joe, site.com/artists/mary, etc.

Question 1: Although it’s not explicitly in the documentation, I thought from reading various forum posts that I could link use the article’s url-title to call the same-named categories:

<txp:smd_gallery category="?title" sublevel="all" form="gallery" />

This doesn’t output anything — is it the wrong syntax? (For the time being I’m just making a custom field, called cat-title, with the same text as the url_title (<txp:smd_gallery category="?cat-title" sublevel="all" form="gallery" />) and that outputs the correct images just fine.

Question 2 (the biggie): is there any way to page by category to fake another level of sub-navigation? I’m trying to put Joe’s Portfolio 2 on a different page from his Portfolio 1, but I can’t seem to do that.

Maybe the next best option is to use onchange, wrap each category in a different div, and make javascript-driven tabs instead of actual pages?

Thanks for any thoughts/solutions!

Offline

#683 2010-05-14 15:38:55

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

Re: smd_gallery: super-flexible gallery generator

jmuspratt wrote:

<txp:smd_gallery category=”?title” sublevel=“all” form=“gallery” />

Very close!

<txp:smd_gallery category="?url_title" sublevel="all" form="gallery" />

(title will get the article’s title — spaces and all).

is there any way to page by category to fake another level of sub-navigation?

Yes, but it might require some trickery (htaccess if you’re comfortable with it) and/or another plugin to make it simpler. Or you can go with a few lines of PHP.

See, the cool thing about TXPs URLs is that anything after the last thingamybob (in your case, the article) is ignored by TXP. But it honours it and passes it along. So all we need to do is make up some fake URLs of the form /section/artist/portfolio_category and then read them in with the aformentioned snip of PHP.

In your article form somewhere you can put this (you can take out all the comments if you like — it’s mostly comments!) :

<txp:php>
global $variable, $thisarticle;

// Read the URL and grab the thing after the last slash.
// This'll either be the author's landing page (their name) OR the name of a portfolio category, so
// set up a txp:variable containing the sub-category. If it doesn't exist, use the author's name later
$variable['chosen_cat'] = array_pop(explode('/', serverset('REQUEST_URI')));

// Set up a txp:variable containing the artist's name (as it appears in the URL)
$variable['theArtist'] = array_pop(explode('/', $thisarticle['url_title']));

if (empty($variable['chosen_cat']) || $variable['chosen_cat'] == $thisarticle['url_title']) {
   // If this is a landing page, limit the thumbnails in each category to just four
   $variable['chosen_cat'] = $variable['theArtist'];
   $variable['thumblim'] = '4';
} else {
   $variable['thumblim'] = '99999';
}
</txp:php>

<txp:hide> Create a navlist of all categories under the current author's image cat </txp:hide>
<txp:category_list type="image" parent='<txp:variable name="theArtist" />' exclude='<txp:variable name="theArtist" />'>
   <a href="<txp:permlink />/<txp:category />"><txp:category /></a>
</txp:category_list>

<txp:hide> The gallery uses the chosen category (which may be the author's name)
    Note that it splits the categories onchange, so if you're on the author's landing
    page, you see a portfolio of all their work from each category.
</txp:hide>
<txp:smd_gallery category="?chosen_cat" sublevel="all" onchange="category_title" onchangewraptag="h3" thumblimt="2">
{onchange:category_title} {object}
</txp:smd_gallery>

Hopefully that’ll do what you want :-) There are probably more elegant solutions out there; perhaps someone else can help in this regard.

Last edited by Bloke (2010-05-14 15:47:55)


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#684 2010-05-14 15:46:21

jmuspratt
Member
From: Nashville, TN
Registered: 2004-10-27
Posts: 54
Website

Re: smd_gallery: super-flexible gallery generator

Fantastic, thanks so much! Will try it out and report back…

Offline

#685 2010-05-16 22:06:01

jmuspratt
Member
From: Nashville, TN
Registered: 2004-10-27
Posts: 54
Website

Re: smd_gallery: super-flexible gallery generator

This is working perfectly. Thanks again!

The only thing I can’t figure out is how to highlight the current image category in the list. Clearly we have access to the current category with $variable[‘chosen-cat’], so I thought that during the category_list loop I should be able to compare each value against it:

<txp:category_list break="" type="image" parent='<txp:variable name="theArtist" />' exclude='<txp:variable name="theArtist" />'>
<li<txp:php global $variable; if ($variable['chosen_cat'] == $GLOBALS['pretext']['c']) {echo "class='current'"}></txp:php>><a href="<txp:permlink />/<txp:category />"><txp:category title="1" /></a></li>
</txp:category_list>

But that throws an error about not having a txp:article tag on the line or something. Does the $GLOBALS[‘pretext’][‘c’] not refer to the current value of txp:category when it’s in a category_list loop like this? Any thoughts?

Last edited by jmuspratt (2010-05-16 22:06:42)

Offline

#686 2010-05-17 08:20:55

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

Re: smd_gallery: super-flexible gallery generator

jmuspratt wrote:

This is working perfectly. Thanks again!

No probs.

The only thing I can’t figure out is how to highlight the current image category in the list

How about using TXP tags instead? Since the $variable simply sets a txp:variable of the given name, you should be able to do something like this:

<txp:category_list break="" type="image" parent='<txp:variable name="theArtist" />' exclude='<txp:variable name="theArtist" />'>
<li<txp:if_variable name="chosen_cat" value='<txp:category />'> class="current"</txp:if_variable>><a href="<txp:permlink />/<txp:category />"><txp:category title="1" /></a></li>
</txp:category_list>

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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#687 2010-05-17 20:44:24

jmuspratt
Member
From: Nashville, TN
Registered: 2004-10-27
Posts: 54
Website

Re: smd_gallery: super-flexible gallery generator

Perfect — thank you again!

Offline

#688 2010-05-21 13:09:55

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

Re: smd_gallery: super-flexible gallery generator

Stef,

This follows your earlier reply here

In an article custom call we get these values

<txp:article_custom>
   <txp:php>
   global $article_info;
   $article_info[upm_img_id(array())] = array(
         'id' => article_id(array()),
         'title' => title(array()),
         'category' => category1(array()),
         'category_t' => category1(array('title' => '1')),
         'section' => section(array()),
      );
</txp:php>
</txp:article_custom>
<txp:smd_gallery form="smd_call" />

Then in the txp:smd_gallery form call:

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

Using: ‘title’ => title(array(‘url_title’ => ‘1’)) in the article_custom call fires errors
Using: $article_info[{id}][‘url_title’] in the smd_gallery call simply outputs nothing
Or other combinations doesn’t work…

Thanks !


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

Hablablow + Webdesignofficina

Offline

#689 2010-05-21 13:28:54

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

Re: smd_gallery: super-flexible gallery generator

hablablow

I didn’t realise when you wrote in the other thread you were doing this. You don’t need to access the variable directly then, because there’s a TXP tag <txp:article_url_title> to help out. But before you can use it in your form, you’ll need to add the info to the array:

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

You can then access $article_info[{id}]['url_title'].


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

Hire Txp Builders – finely-crafted code, design and Txp

Offline

#690 2010-05-21 13:33:06

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

Re: smd_gallery: super-flexible gallery generator

Yeepee yay !

Thank you sooooooooooo much Stef !

:)


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

Hablablow + Webdesignofficina

Offline

Board footer

Powered by FluxBB