Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#49 2005-02-02 23:41:00

nvalvo
New Member
From: San Francisco
Registered: 2005-01-18
Posts: 6
Website

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

#50 2005-03-02 14:45:08

Matt
Member
Registered: 2004-02-28
Posts: 92
Website

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

#51 2005-03-02 15:43:00

wilshire
Plugin Author
From: Akron, Ohio
Registered: 2004-08-27
Posts: 656
Website

Re: [archived] jmr_gallery : Article Associated Image Gallery

Here I am again!

Try changing it to <code>$_SERVER[‘REQUEST_URI’]</code>

Offline

#52 2005-03-02 18:05:18

ChrisJ
Member
From: Vienna, Austria
Registered: 2004-03-30
Posts: 54
Website

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

#53 2005-03-02 18:20:26

Matt
Member
Registered: 2004-02-28
Posts: 92
Website

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

#54 2005-03-02 19:14:52

ChrisJ
Member
From: Vienna, Austria
Registered: 2004-03-30
Posts: 54
Website

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

#55 2005-03-02 20:55:53

Matt
Member
Registered: 2004-02-28
Posts: 92
Website

Re: [archived] jmr_gallery : Article Associated Image Gallery

OK. The code is here for reading and here for downloading. Hope it helps.

EDIT: I can’t get the html version to work. Hope to fix it soon…

Last edited by Matt (2005-03-02 20:57:15)

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

#57 2005-03-09 17:43:24

Matt
Member
Registered: 2004-02-28
Posts: 92
Website

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

#59 2005-04-03 05:57:34

NeilA
Member
From: Blue Mountains, Australia
Registered: 2004-08-15
Posts: 316
Website

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


Neil – Blue Mountains, Australia

http://westserve.org
http://ministrygrounds.net.au

Offline

#60 2005-04-03 12:41:38

Matt
Member
Registered: 2004-02-28
Posts: 92
Website

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

Board footer

Powered by FluxBB