Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: [archived] jmr_gallery : Article Associated Image Gallery
Hey guys:
It looks as though no one is really that interested anymore, but I just did my first “real” php hack, and I’m very proud, cuz it works. I’ll explain in sufficient detail for fellow non-php coders, so that they can make this change also.
My efforts to make jmr_gallery work better with messy urls (which I must use, because I am on a subdomain, so clean doesn’t work), ran up against this problem: When I clicked on the ‘Next’ or ‘Previous’ link, it submitted a url something like this:
<code>
www.mysite.com/index.php?imagenum=2
</code>
This meant, on messy URLs, that it returned to the homepage, because the url no longer said <code>?id=15</code> or whatever. That is, the link was associated with the image and not the article.
So obviously, what was needed was a way to make the links produce
<code>
www.mysite.com/index.php?id=15&imagenum=2
</code>
Here’s what you do. You just insinuate another variable into the links.
The four (two if an imagenum is not yet set, two if it is) lines in the plugin that produce the links need to read as follows:
<code>
$nextlink=’<a href=”’ . str_replace(‘//’,’‘,$_SERVER[‘PHP_SELF’] . ‘?id=’ . $thisarticle[‘thisid’] . ‘&imagenum=’) . $nextimage . ‘”>Next image »</a>’;
</code>
and
<code>
$prevlink=’<a href=”’ . str_replace(‘//’,’‘,$_SERVER[‘PHP_SELF’] . ‘?id=’ . $thisarticle[‘thisid’] . ‘&imagenum=’). $previmage . ‘”>« Previous image</a>’;
</code>
Nice! I am so psyched.
Nick
Last edited by nvalvo (2005-02-03 00:48:35)
http://www.nvalvo.com
http://www.factbasedcommunity.com
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
I’m having trouble making this work with RC3 and clean URLs.
Apparently the $_SERVER[‘PHP_SELF’] variable returns index.php as part of the URL, which I need to remove. Is there a php or Txp global that can return the actual clean URL that has been used to open the page? If so, I can build the link with that.
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
Here I am again!
Try changing it to <code>$_SERVER[‘REQUEST_URI’]</code>
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
Not quite what it should be. It changes index.php into /section/post_id – but only from first to second image. When going from second to third, URL looks like /section/id/?imagenum=2?imagenum=3.
Without trailing slash in the location bar, it doesn’t work at all, even for first to second image (post_id?imagenum=2).
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
I hacked it until it broke, then tried to undo everything I had done, and now it seems to work just fine. So I can’t explain what I did or why it now works, but if you want my code from the link-creating lines, let me know and I’ll post it.
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
Sure, Matt! Could you save the whole plugin code in a text file and link here. That would be great.
Offline
Offline
#56 2005-03-09 17:23:59
- lex
- Member
- From: Baltimore
- Registered: 2004-04-23
- Posts: 12
Re: [archived] jmr_gallery : Article Associated Image Gallery
Matt –
I tried to upload that and got: Badly formed or empty plugin code?
With an Apple, everything is either easy or impossible. – Unknown
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
You can’t install my code like a plugin. It’s just the functional php code. Try installing the canonical version, then go to “edit” and replace all the code with mine.
Sorry for the less-than-professional approach: if I knew how, I’d have coded my own gallery plugin by now based on this one.
Last edited by Matt (2005-03-09 17:43:49)
Offline
#58 2005-03-09 18:53:43
- lex
- Member
- From: Baltimore
- Registered: 2004-04-23
- Posts: 12
Re: [archived] jmr_gallery : Article Associated Image Gallery
AH!! Thanks!
With an Apple, everything is either easy or impossible. – Unknown
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
Maybe I’m missing something, but is there anyway of controlling the order that the images are displayed in using this plugin?
Or is it just taken from the images were uploaded?
Thanks
Offline
Re: [archived] jmr_gallery : Article Associated Image Gallery
I think they are sorted by their ID numbers, which is a product of the order they were updated. If someone adopts this plugin and continues development, he or she ought to add a sort field.
Offline