Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-12-12 21:22:11

jeroen
Member
From: brussels.be
Registered: 2012-06-15
Posts: 16

hijack article link in certain sections

Hello,

I’m having trouble abstracting this question from my particular use case, so I’ll just post what I’d like to achieve.

http://somesiteimbuilding.com/team loads a page with a list of team members. (Each team member in the list is an article in the “team” section).
In addition, each of these articles is written to that same page as hidden content, to use as a popup modal window.

When you click a team member, javascript pops up that team member’s modal, showing the specific info.

-

I would now like to be able to link to a specific team members modal.
http://somesiteimbuilding.com/team/some-person
I would need to extract the article’s URL-only title from the request, load the “team” section page and use the data extracted from the URL-only title to fire up the modal using javascript.

I had a look at adi_gps but that one seems to only work with custom post or get data (unless I’m missing something).

Would something like this be possible?

I hope I made myself clear,
thank you for reading this far… :)

Cheers,
Jeroen

Offline

#2 2012-12-12 22:39:23

Gocom
Developer Emeritus
From: Helsinki, Finland
Registered: 2006-07-14
Posts: 4,533
Website

Re: hijack article link in certain sections

If you do want to fire JavaScript, you could (and should) use #hashes to active certain events (e.g. the modal popup). This would give you links such as http://somesiteimbuilding.com/team#some-person. You can use window.location.hash to get that hash from the request and fire appropriate JavaScript (typically events, or modals internal methods) based on it. In general you should always use anchors (or fake location paths) for any JavaScript based Ajax driven navigation so that users can directly links to the content (or navigate back, reload page on error).

As far as URL-only title goes, you can retrieve it from the requested page using article_url_title tag. Article tags display the content applicable for the context. No URL parsing is required (or suggested).

Offline

#3 2012-12-12 22:48:24

jeroen
Member
From: brussels.be
Registered: 2012-06-15
Posts: 16

Re: hijack article link in certain sections

Ater posting this question I had the insight to check the article tags for <txp:article_url_title /> indeed. Writing stuff down does make it make more sense.
But I understand the preference for using #. First time I hear about window.location.hash, I have to admit.

Thank you for your fast end very helpful response!

Another trick up my sleeve…

Offline

Board footer

Powered by FluxBB