Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2012-06-10 04:03:30

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Use article-url-title as article_custom selector?

Input: article-url-title (in a variable)

Desired output: article_custom block for only the article with a matching URL title.

For example, my needs would be met if there was an “article_url_title” attribute in article_custom, like so:

<txp:article_custom section="manufacturers" article_url_title="manufacturer-name-here" form="mfg_display" />

My brain is toast (too much adi_gps, adi_calc, etc…) so I’m thinking maybe I’m forgetting something…but thanks for any help.

Last edited by maruchan (2012-06-10 04:03:53)

Offline

#2 2012-06-10 05:04:48

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,172
Website GitHub Mastodon Twitter

Re: Use article-url-title as article_custom selector?

Hi Marc, what do you mean with article_url_title? I take it that you don’t mean URL only title which has to be a unique entry on each post for some url schemas.


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#3 2012-06-10 05:48:50

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: Use article-url-title as article_custom selector?

Yes, I do mean URL only title. You see, I want to retrieve this exact article in order to display its imagery, body text, etc.

I have two sections, one for products, one for manufacturers.

If you are on the manufacturers page, there is a feature that will “show all manufacturers that make large widgets”. So I capture the widget size via a URL variable named “size”. Then after I sanitize the variable, I do this:

<txp:article_custom size='<txp:variable name="size" />' sort="Section" limit="9999">
  <txp:if_different>
    <txp:variable name="matching-section"><txp:section /></txp:variable>
  </txp:if_different>
</txp:article_custom>

…now that was just a test, but I have the name of the section(s) where there are items of that size. OK, now I need to render those manufacturers’ information. So I want to change the above to something like this:

<txp:article_custom size='<txp:variable name="size" />' sort="Section" limit="9999">
  <txp:if_different>
    <txp:variable name="matching-section"><txp:section /></txp:variable>
    <txp:article_custom section="manufacturers" url_only_title='<txp:variable name="matching-section" />' >
       <h1><txp:permlink><txp:title /></txp:permlink></h1><!-- Manufacturer name -->
       <!-- body, excerpt, image, whatever goes here -->
     </txp:article_custom>
  </txp:if_different>
</txp:article_custom>

(I’m using url_only_title above, to answer your question) Does that sort of make sense? :-) I already have articles in the manufacturers’ section that are named with the correct URL-only-title.

…I guess I could change the articles’ URL only titles to match their ID number…I know article_custom will allow ID. :-) But that would be ugly in the URL.

Last edited by maruchan (2012-06-10 05:54:57)

Offline

#4 2012-06-10 06:28:40

colak
Admin
From: Cyprus
Registered: 2004-11-20
Posts: 9,172
Website GitHub Mastodon Twitter

Re: Use article-url-title as article_custom selector?

maruchan wrote:

…I guess I could change the articles’ URL only titles to match their ID number…I know article_custom will allow ID. :-) But that would be ugly in the URL.

Or you could use a custom_field there… if it was called “brand” something like:

   <txp:article_custom section="manufacturers" brand='<txp:variable name="matching-section" />' >

should work


Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.

Offline

#5 2012-06-10 06:32:14

maruchan
Member
From: Ukiah, California
Registered: 2010-06-12
Posts: 596
Website

Re: Use article-url-title as article_custom selector?

Ah, that makes sense. Even a category would work, I suppose. I was just thinking in terms of using what’s already there. Thanks, I’ll probably do that.

Offline

Board footer

Powered by FluxBB