Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-07-15 12:55:20

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

<if_category type=""> and section context

The type attribute for if_category appeared with TXP 4.3. I tested:

<txp:category_list label="articles categories" wraptag="p" break="br" type="article" />
<txp:category_list label="Link categories" wraptag="p" break="br"  type="link" />
<txp:category_list label="image categories" wraptag="p" break="br" type="image" />
<txp:category_list label="file categories" wraptag="p" break="br" type="file" />

<txp:if_category>
   ::: DEFAULT CATEGORY CONTEXT :::
</txp:if_category>
<txp:if_category type="article">
   ::: ARTICLE CATEGORY CONTEXT :::
</txp:if_category>
<txp:if_category type="link">
   ::: LINK CATEGORY CONTEXT :::
</txp:if_category>
<txp:if_category type="image">
   ::: IMAGE CATEGORY CONTEXT :::
</txp:if_category>
<txp:if_category type="file">
   ::: FILE CATEGORY CONTEXT :::
</txp:if_category>

In a context category only, there is no problem :
url /category/file/file-cat-1/ return ::: FILE CATEGORY CONTEXT ::: and url /category/article-cat-1/ return ::: DEFAULT CATEGORY CONTEXT ::: ::: ARTICLE CATEGORY CONTEXT :::
All seems ok

But if I add a section attribut to category_list to be in a “section + category + type” context :
<txp:category_list label="Link categories" wraptag="p" break="br" section="about" type="link" />
url /about/?c=link-cat-1&context=link return ::: DEFAULT CATEGORY CONTEXT ::: ::: ARTICLE CATEGORY CONTEXT :::, the <if_cat type="article"> content an not the <if_cat type="link"> content

Is this a normal behavior or a bug ?

Offline

#2 2011-07-21 17:13:46

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: <if_category type=""> and section context

the nightmare continued …

Another problem with the context url/category/type/category-name
This time is directly related to language files.

If the back is in English (preferences – language) without any problems I go to the url ulr/category/file/private

But if the language of the back office is French, texpattern returns a 404 error for that url.

Could someone confirm or deny my observations?

Offline

#3 2011-07-21 17:51:44

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: <if_category type=""> and section context

AAAAHHHH
I’m going crazy.

you have a link to a context category
<txp:category type="image" link="1" name="image-cat- 1" />

If your language is English the url of link is:
site-url/category/image/image-cat-1/
If your language is French, the URL is:
site-url/catégorie/image_context/image-cat-1/
If your language is Italian, the URL is:
site-url/categoria/immagine/image-cat-1/
etc.

I never found it. Is this documented somewhere?

Offline

#4 2011-07-21 18:59:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: <if_category type=""> and section context

sacripant wrote:

If your language is English the url of link is:
site-url/category/image/image-cat-1/
If your language is French, the URL is:
site-url/catégorie/image_context/image-cat-1/
I never found it. Is this documented somewhere?

Ahem *blush* well I documented it on the thread as it was being developed, and it was noted in the changesets and in the code. It just never made it to the documentation.

Since Txp outputs URLs in the localised language, I figured if_category should also function that way. Behind the scenes it uses the name (not “Localised Title”) but the URL matching is done based on the currently active language.

Where’s the best place to document this? On the if_category tag page? Somewhere else?

Last edited by Bloke (2011-07-21 19:00:16)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2011-07-21 23:25:07

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: <if_category type=""> and section context

Bloke wrote:

Where’s the best place to document this?

I think it could be mentioned on the Admin > Languages Tab page what consequences it might have to copy URLs and paste them into articles before the final admin language is chosen.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#6 2011-07-22 12:55:18

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: <if_category type=""> and section context

Steph thank you for your clarification.

I know nothing in url / uri. Some questions:

  • I thought that url could not contain special characters éêâàç?
  • What append for SEO, bots, crawler, if you change the language of a production site?
  • I not understand. Why translate category but not the category type, and use the category name and not his title ? exemple:
    • url in english: site-url/category/file/bonjour_mon_garcon
    • in French, category become catégorie with é: ok.
    • file becomes file_context (it’s not French, it’s English) and should be fichier.
    • bonjour_mon_garcon is the name of the category, with no special characters, but if special characters are used to catégorie why not use the title instead of name ?

Last question, other subject:

- Why condition <if_category type="file || image || link"> does not work in a section context (see my first post)? I have not found information on the documentation about it.

@Uli,
good idea

Offline

#7 2011-07-22 13:49:35

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,453
Website GitHub

Re: <if_category type=""> and section context

sacripant wrote:

I thought that url could not contain special characters éêâàç?

I thought so too but txp has been doing it that way forever. Didn’t want to break the tradition. From a code perspective it’d be easier all round if the URL used the English version, but history is history.

What append for SEO, bots, crawler, if you change the language of a production site?

Ummm, dunno. Guess links break. Bad.

in French, category become catégorie with é: ok. file becomes file_context… and should be fichier.

It’s defaulting to the internal name because file_context has not been translated into French on the RPC server.

bonjour_mon_garcon is the name of the category, with no special characters, but if special characters are used to catégorie why not use the title instead of name ?

History again: Txp has always done it that way and if we changed it we’d break a lot of stuff in the 4.x branch.

Why condition <if_category type="file || image || link"> does not work in a section context

Files, images and links don’t understand the concept of a Section: only articles can be put in sections. The day we can assign files to a section, if_category will work as you expect.

Last edited by Bloke (2011-07-22 13:50:06)


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#8 2011-07-22 16:16:12

sacripant
Plugin Author
From: Rhône — France
Registered: 2008-06-01
Posts: 479
Website

Re: <if_category type=""> and section context

Bloke wrote:

Ummm, dunno. Guess links break. Bad.

I think it’s important to detailed this in the documentation.
Put a warning in the back office in the choice of language ?

Does “gbp_permanent_links” can fix the url regardless of the language ?

It’s defaulting to the internal name because file_context has not been translated into French on the RPC server.

Ok.

Files, images and links don’t understand the concept of a Section: only articles can be put in sections. The day we can assign files to a section, if_category will work as you expect.

of course, it makes sense… I need holidays

Offline

#9 2011-10-04 07:27:47

Pat64
Plugin Author
From: France
Registered: 2005-12-12
Posts: 1,634
GitHub Twitter

Re: <if_category type=""> and section context


Patrick.

Github | CodePen | Codier | Simplr theme | Wait Me: a maintenance theme | [\a mi.ni.ma]: a “Low Tech” simple Blog theme.

Offline

Board footer

Powered by FluxBB