[pmwiki-users] PData support for pagelisting images

Patrick R. Michaud pmichaud at pobox.com
Thu Sep 7 12:13:16 CDT 2006

On Thu, Sep 07, 2006 at 04:00:33PM +0000, Pico wrote:
> Patrick R. Michaud <pmichaud <at> pobox.com> writes:
> > 
> > On Thu, Sep 07, 2006 at 01:56:00PM +0000, Pico wrote:
> > > Will the new PData {$:var} support pagelisting images?  
> > > 
> > > In a quick test, I was able to use PData to grab a single image (and 
> > > image link), but could not accomplish the same thing using pagelist 
> > > to grab multiple images.  See Test/PData#thumbs.  
> > 
> > It looks like it's working to me -- what are you expecting to see
> > that you're not seeing?
> > 
> I'm seeing something like this:
>  ___________________________________________________________________________
> |(:pagelist fmt=#showthumbs group=Test name=EasyGalleryPic* "Thumbnail:" :) |
> |---------------------------------------------------------------------------|
> | [_______________________________]                                         |  
> |___________________________________________________________________________|

Oh, I was looking at the wrong part.

I'm not entirely sure why the pagelist part in Test.PData isn't working.
I suspect it has something to do with the order in which markup
substitutions are taking place inside the pagelist output.  Or perhaps
there's just something else weird about the Test.PData page.

Since the implementation of pagelists and page content variables is going
to be substantially reworked anyway, I'm not wanting to spend too much
time tracking this particular one.

Also, I think there's a far easier way to do what you're trying to do -- 
see below, under "An easier gallery".

> Note, a second issue is the way that the thumbnail links work.  
> [...]

One of the things that *greatly* concerns me about the {$:var} markup
is that authors are going to get very confused by trying to put
page variables in the values.

For example, on http://www.pmwiki.org/wiki/Test/EasyGalleryPic1, there is:

    Thumbnail: %thumb%Attach:HaleyDog.jpg%%
    Thumbnailink: %thumb%[[{$FullName}|Attach:HaleyDog.jpg"{$Title}"]]%%

Okay so far, but look at what happens when another page, say Test.XYZ,
uses "{EasyGalleryPic1$:Thumbnailink}".  The page content variable
is replaced by the Thumbnailink: line from EasyGalleryPic1 -- that is:


But when Test.XYZ evaluates this string, we'll get the name and title
of Test.XYZ, not the name and title of EasyGalleryPic1 (where it came from).

It gets worse when we have a page called SomePage with:

    FirstName: Patrick
    LastName: Michaud
    FullName: {$:FirstName} {$:LastName}

because an author using {SomePage$:FullName} is going to expect the result to
grab the FirstName and LastName values out of SomePage and not the current page.

I've thought about it a fair bit, and I'm not sure I like any of the
alternatives.  No matter what is chosen we're likely to come up with 
something that is very confusing to some.


An easier gallery

If we just want to create a gallery of images and thumbnails, and we have
the {$:var} markup available, we don't need any additional special Thumbnail:
or Thumbnailink: properties in picture pages to do it.  Just define the 
picture pages using normal markup, as in:

    !! Haley

    This is a picture of Haley at one year old.

    Categories: [[!Animals]] [[!Dogs]]

and then our gallery pagelist template can be:

    (:if equal {<$Group}:)
    >>lframe width=300px<<
    (:if !equal {=$:Attach}:)%thumb%[[{=$FullName}|Attach:{=$FullName}/{=$:Attach}]]

Okay, so how does this work?  Well, the value of {EasyGalleryPic1$:Attach} is
going to be "somepic.jpg" -- the thing that follows the "Attach:" markup
in the EasyGalleryPic1 page.  So, we can use the {...$:Attach} markup in a
pagelist template to grab an attachment from each page in the list.  For
the above [[#gallery]] template, it's given by


so that for EasyGalleryPic1, we end up with


which is exactly what we wanted -- a link to the EasyGalleryPic1 page
with its attachment as link text.

Since a picture page might contain multiple attachments, or we might
want to add some styling or a caption to the image on the EasyGalleryPic1
page, a slightly better approach might be to set the page as:

    !! Haley

    Image:: somepic.jpg

    %cframe% Attach:{$:Image} | here's my caption
    This is a picture of Haley at one year old.

and then use {=$:Image} instead of {=$:Attach} in the pagelist.

*Lots* to think about here.


More information about the pmwiki-users mailing list