Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-08-31 09:02:44

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Hi,

I’m aiming to write a plugin (based off zem/hak_article_image) that lists (with either thumbs or numbers) all article images for a specific article. A good example would be multiple images for a portfolio entry. An entry will have the main image displayed in full size, with the other available images displayed underneath using the thumbnail images. When a thumbnail is clicked, its full version is displayed in the main (normal sized) image above.

The ‘problem’ is that I need to pass the image number from page to page (I’d like the page to reload itself).

Would it be possible for me to append an attribute to the URL, i.e. make the created thumbnail links point to:

http://website.com/section/articleName/?imageID=x

I could then search for a specific ‘imageID’ within the plugin (simple URI search) and display the corresponding image. This would be a simple process as each image stored within TXP is numbered with its own ID anyway.

If that is not possible, is there some kind of TXP-system-wide variable I could use? I know exactly what I want to achieve, but I only know C/C++/Java/JSP, so I’m not sure how to get this working in a TXP plugin.

Any help/pointers/examples would be appreciated very much!

Edit: Apologies if this should have been in the How To section, I posted here as it is plugin specific, not a general question.

Offline

#2 2005-08-31 17:59:02

Mary
Sock Enthusiast
Registered: 2004-06-27
Posts: 6,236

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Knowing those languages is quite useful. From the PHP manual: “Its syntax draws upon C, Java, and Perl, and is easy to learn.”
http://www.php.net/manual/en/langref.php

Not only does PHP have many built-in functions to do all kinds of things, but Textpattern has its own mini library as well. Check here to see what’s available.

Yes, its possible, and fairly simple. You should account for other url modes as well. You can see how urls are built by looking at the permlinkurl function (thats the function <txp:permlink /> talks to), starting at line 1304 of taghandlers.php.

Build the link with your variable attached to the end, then look for and grab it using the gps() function, line 228 of txplib_misc.php, ie:

<pre><code>if (gps(imageID))
{ //aha! // you’ve come looking for an image!

}</code></pre>

Offline

#3 2005-08-31 18:05:22

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

As usual mary, you have been very helpful. I will look into it – thanks for the advice!

Offline

#4 2005-08-31 20:37:50

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

You could probably get a long way by passing ?p=imageid and using the bulk of <txp:image_display /> for the rest since it already looks for p in the query string and p is checked for in the url scheme checking part of publish.php. I’ve actually been meaning to add something like this to hak_article_image but I’m still trying to figure out the best way to do it. You can get the permalink for the current article by running permlinkurl_id() (and probably other ways also but this seemed to work) and then just check for messy mode before appending to the query string.

Last edited by hakjoon (2005-08-31 20:39:00)


Shoving is the answer – pusher robot

Offline

#5 2005-09-01 02:13:58

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

I updated hak_article_image to version 0.3. This version adds the ability to create a link from the thumbnail to the same page passing the image id (displaylink=“1”). This id can be picked up by <txp:image_display /> or <txp:hak_article_image urloverride="1" />. Maybe this will do some of what you want.

Version 0.3


Shoving is the answer – pusher robot

Offline

#6 2005-09-01 08:06:56

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Edit: Tried this at work (slaps own wrist) and it works <em>perfectly</em>. Thank you VERY much indeed! :¬)

One thing however, I had to set…

<code><txp:hak_article_image urloverride=“0” /></code>

… the URL Override to 0 to get it to override. When I tried 1, the default article image always remained no matter what thumb I clicked. I’m using the latest 4.0 release.

Last edited by BlueMamba (2005-09-01 13:58:12)

Offline

#7 2005-09-01 16:02:34

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Let me look at that tonight. There’s probably some backwards logic that I didn’t catch.

Technically either should work as I think I have it just checking if the attribute exists and has some value, but I’m sure I just goofed something.


Shoving is the answer – pusher robot

Offline

#8 2005-09-01 17:05:58

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Yeah will be a simple logic statement. You’ve made my life so much easier, I can now make my portfolio as intended. BIG thanks to you, Patrick :¬)

Offline

#9 2005-09-01 23:07:27

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

I updated the plugin to version 0.3.1 which I think fixes the logic snafu. Although I was having a hard time replicating it. Let me know if it does it.


Shoving is the answer – pusher robot

Offline

#10 2005-09-02 08:08:29

rossharvey
Member
From: Earth. Sometimes.
Registered: 2005-03-16
Posts: 233
Website

Re: URL Rewriting (or similar) in plugin? (Portfolio Gallery)

Nice, will try it when I return home tonight and let you know.

Offline

Board footer

Powered by FluxBB