Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: some ideas needed for txp 4.8 update
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: some ideas needed for txp 4.8 update
colak wrote #320814:
we do in the categories pane.
Sorry, I wasn’t clear. We offer the administrator a way to apply a hierarchy for Sanity’s sake and to group related categories, but we don’t use it anywhere else. It’s purely for organisational purposes.
If you wanted to, you could assign a “subcat” to category 1 and its parent to category 2. Or the same category to both. Txp would let you.
Last edited by Bloke (2020-01-04 09:18:19)
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
Re: some ideas needed for txp 4.8 update
Bloke wrote #320819:
Sorry, I wasn’t clear. We offer the administrator a way to apply a hierarchy for Sanity’s sake and to group related categories, but we don’t use it anywhere else. It’s purely for organisational purposes.
If you wanted to, you could assign a “subcat” to category 1 and its parent to category 2. Or the same category to both. Txp would let you.
Indeed but the problem lies with the url patterns.
breadcrumb/title
returns sanitised urls based on the hierarchy set in the categories pane. ie if you set categories like
- desserts
- apples
and have an article named apple-pie, the schema will return /section/desserts/apples/apple-pie
which is perfect.In cases like this only one category can be used in the write pane.
The problem with sub-cats when used on cat1 and cat2, the +
sign is used in the url ie /section/cat1+cat2/welcome-to-your-site
and understandably totally ignores the hierarchy, even when there is one.
In reality, although I fully support the latest url schemas, I am finding out that we need slightly more flexibility in order to achieve deeper url structures. This can be achieved in 2 ways
- add another schema which can build urls like
/section/cat1/cat2/title
- as I wrote earlier, allow duplicate category names when using the
/breadcrumb/title/
schema. This may be achieved by adding an id to each title which can then be called in order to differentiate between categories sharing the same name.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: some ideas needed for txp 4.8 update
colak wrote #320820:
The problem with sub-cats when used on cat1 and cat2, the
+
sign is used in the url ie/section/cat1+cat2/welcome-to-your-site
and totally ignores the hierarchy, even when there is one.
If cat2
is a descendant of cat1
, I get /section/cat1/cat2/welcome-to-your-site
as expected. Do you mean we should do it by levels, even if cat1
and cat2
are in different branches?
allow duplicate category names when using the
/breadcrumb/title/
schema.
This is difficult for bw compatibility reasons, one of the difficulties being ?c=catname
URL pattern (whatever scheme) as you note.
Offline
Offline
Re: some ideas needed for txp 4.8 update
etc wrote #320823:
Okay, unconditional
/section/cat1/cat2/title
makes sense insection_category
mode, changed.
Thanks so much Oleg,
I am testing it now!
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: some ideas needed for txp 4.8 update
etc wrote #320822:
If
cat2
is a descendant ofcat1
, I get/section/cat1/cat2/welcome-to-your-site
as expected.
This is indeed true
Do you mean we should do it by levels, even if
cat1
andcat2
are in different branches?
I know it is conceptually problematic but that is what I was implying.
This is difficult for bw compatibility reasons, one of the difficulties being
?c=catname
URL pattern (whatever scheme) as you note.
I understand. The reason I kicked a fuss is because I think that although branches can give a deeper structure, the limitation of names can eventually lead to semantic issues in the urls
ie. /journal/physics/issues/paper
v /journal/quantum-mechanics/issues/paper
.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: some ideas needed for txp 4.8 update
colak wrote #320828:
The reason I kicked a fuss is because I think that although branches can give a deeper structure, the limitation of names can eventually lead to semantic issues in the urls
You are absolutely right, the new implementation is more flexible, thanks for the fuss and don’t stop :-)
Offline
Re: some ideas needed for txp 4.8 update
Is there a way to evaluate if an article belongs to both cat1 AND cat2? I was thinking along the following lines.
Collect all articles from category 2, but as the category names can be generic I will possibly also get articles which do not have the same category 1
<txp:variable name="cat2">
<txp:article_custom section='<txp:section />' category='<txp:category2 />' limit="999" break=",">
<txp:article_id /></txp:article_custom>
</txp:variable>
<txp:article_custom id='<txp:variable name ="cat2" />' break="li" wraptag="ul">
<txp:if_article_category name='<txp:category1 />'>
<txp:title />
</txp:if_article_category>
</txp:article_custom>
or
<txp:variable name="cat2">
<txp:article_custom section='<txp:section />' category='<txp:category2 />' limit="999" break=",">
<txp:article_id />
</txp:article_custom>
</txp:variable>
<txp:article_custom id='<txp:variable name ="cat2" />' break="li" wraptag="ul">
<txp:evaluate test="category1">
<txp:title />
</txp:evaluate>
</txp:article_custom>
or a clever way of using the related_articles
tag in a section/cat1/cat2/ listing page?
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline
Re: some ideas needed for txp 4.8 update
etc wrote #320823:
Okay, unconditional
/section/cat1/cat2/title
makes sense insection_category
mode, changed.
Oh, that is real nice. For some reason when I originally tested those new URL patterns I thought this would not possible and then didn’t think more about it. TY both Colak for insisting and Oleg for implementing.
Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern
Offline
Re: some ideas needed for txp 4.8 update
colak wrote #320838:
Is there a way to evaluate if an article belongs to both cat1 AND cat2?
If you don’t care about pagination, the simplest way seems to be
<txp:variable name="cat1" value='<txp:category1 />' /> <!-- or whatever -->
<txp:variable name="cat2" value='<txp:category2 />' />
<txp:article_custom category='<txp:variable name="cat1" />, <txp:variable name="cat2" />' limit="999" trim>
<txp:evaluate query='"<txp:category1 />"="<txp:variable name="cat1" />" and "<txp:category2 />"="<txp:variable name="cat2" />"'>
<txp:title />
</txp:evaluate>
</txp:article_custom>
If you are sure no cat2
value is used as cat1
, you can optimize it:
<txp:article_custom category='<txp:variable name="cat2" />' match="Category2" limit="999" trim>
<txp:evaluate query='"<txp:category1 />"="<txp:variable name="cat1" />"'>
<txp:title />
</txp:evaluate>
</txp:article_custom>
or a clever way of using the
related_articles
tag in a section/cat1/cat2/ listing page?
Currently related_articles
works only in individual article context and uses the same OR
logic as article_custom
. But we can tweak it for 4.8 release.
phiw13 wrote #320843:
Oh, that is real nice. For some reason when I originally tested those new URL patterns I thought this would not possible and then didn’t think more about it. TY both Colak for insisting and Oleg for implementing.
Please retest whether everything works as expected, thanks.
Offline
Re: some ideas needed for txp 4.8 update
Thanks so much Oleg. I’m testing your suggestions which are not quite working in my pages yet but I know that it is possibly my fault. I’ll keep on trying.
Yiannis
——————————
NeMe | hblack.art | EMAP | A Sea change | Toolkit of Care
I do my best editing after I click on the submit button.
Offline