Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-12-29 18:57:50

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

some ideas needed for txp 4.8 update

The neme.org site is currently listing our projects as they happen. That is,

/project/article-10
/project/article-9
/project/article-8
/project/article-7
etc

The problem we had up to now is the issue of projects consisting of many events some of which deserve their own page.
At the moment our url schema uses the /section/page option but with the new url schema we will be able to have a ‘deeper’ option such as /section/category/page.

The problem I am trying to solve lies in this page. Any ideas on how we could automatically insert category names in that timeline? The result I am trying to achieve is

/project/article-10
/project/article-9
/project/category-8/
project/article-7
etc

I am thinking of using article titles as a placeholders for the categories and permlink based variables in order to replace those urls.
Alternatively, would a use of a custom field be more sustainable?

Am I thinking on the right lines and are any of the ideas actually doable or will my head scratching be in vain?


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

Offline

#2 2019-12-29 19:39:44

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

Re: some ideas needed for txp 4.8 update

Not sure I quite understand whether you’re trying to add hyperlinkable category headings above a bunch of articles in the same category or if you’re replacing some articles with links to a category. If the latter, how do you know which ones you want to ‘do the category’ with? That might give a clue on how this is best approached.

Either way, I presume the code in question is from your events page?

<txp:article limit="999">
<article><div class="grid_5"><txp:if_logged_in><p><a href="<txp:site_url />textpattern/index.php?event=article&amp;step=edit&amp;ID=<txp:article_id />"><txp:custom_field name="dates" escape="" /></a></p><txp:else /><p><txp:custom_field name="dates" escape="" /></p></txp:if_logged_in></div>
<div class="grid_6"><h6><a href="<txp:permlink />" rel="bookmark"><txp:title /></a></h6></div>
<div class="grid_13"><txp:if_custom_field name="venues">
<p><txp:custom_field name="venue" escape="" /> <txp:custom_field name="venues" escape="" /></p>
<txp:else />
<p><txp:custom_field name="venue" escape="" /></p>
</txp:if_custom_field></div>
<div class="clearboth"><hr class="noprint" /></div></article>
</txp:article>

The permlink returned will be the one assigned to the ‘events’ section. Unless you start building your permlinks by hand, that’s what you’ll get. If you choose the category-based permlink mode, you’ll get the category(ies) in the URL. But they’ll still resolve to a single article when clicked.

So what do you want the visitor to do? Do they sometimes visit a single article when clicking an item in the list, but sometimes ‘drill down’ from this event page to a ‘category list page’ which has its own set of articles? If so, again, how do you know to which articles this applies? As you’re iterating over the list of articles, you need some way to distinguish them so you can take action.

Oh, and also, you should be able to simplify your <txp:if_custom_field> venues thing in 4.8. You shouldn’t need the conditional.


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

#3 2019-12-30 06:45:12

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

Re: some ideas needed for txp 4.8 update

Hi Stef, thanks for the reply. I’m glad I confused you as much as I am confused:) I’ll try to make it clearer.

Some of our projects are straight forward. They have a couple of events each (such as an exhibition and a seminar). For those projects we just devote an article in the events page. Other projects though are much more complex and we would like to document them more thoroughly using two or more articles.

At the same time we would like to keep the chronological list of all the projects in the /events/ landing page.

Basically I would like to fudge a directory structure.

The untested code below builds on the snippet you correctly posted above in order to demonstrate one of the options I was thinking of. The code assumes that a category name will be the same as an article’s permlink and adds a / at the end of the permlink in order to link to a category page from which I could host content of the faux directory.

<txp:article limit="999">
<txp:if_article_category name='<txp:page_url escape="" />'>
<p><txp:custom_field name="dates" escape="" /></p>
<h6><a href="<txp:permlink />/" rel="bookmark"><txp:title /></a></h6>
<txp:if_custom_field name="venues">
<p><txp:custom_field name="venue" escape="" /> <txp:custom_field name="venues" escape="" /></p>
<txp:else />
<p><txp:custom_field name="venue" escape="" /></p>
</txp:if_custom_field>
<txp:else />
<p><txp:custom_field name="dates" escape="" /></p>
<h6><a href="<txp:permlink />" rel="bookmark"><txp:title /></a></h6>
<txp:if_custom_field name="venues">
<p><txp:custom_field name="venue" escape="" /> <txp:custom_field name="venues" escape="" /></p>
<txp:else />
<p><txp:custom_field name="venue" escape="" /></p>
</txp:if_custom_field>
</txp:if_article_category>
</txp:article>

This is just the first thing I am trying to solve. I will also need to exclude articles which will act as placeholders for subcategories.

Maybe a way to understand the goal for this is to imagine our R! subdomain migrating to our main domain under the events section.

For that to happen, we will need urls like
/events/respublika/
/events/respublika/exhibitions/
/events/respublika/exhibitions/exhibition-title1
/events/respublika/exhibitions/exhibition-title2
/events/respublika/festival/
etc

From the above urls, we would like to have only the first one (/events/respublika/) appearing in the events section home 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

#4 2019-12-30 07:54:14

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

Re: some ideas needed for txp 4.8 update

Maybe I should simplify the code in order to make the concept more readable

<txp:article limit="999">
<txp:if_article_category name='<txp:page_url escape="" />'>
<a href="<txp:permlink />/" rel="bookmark"><txp:title /></a>
<txp:else />
<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
</txp:if_article_category>
</txp:article>

Edited to add that I am not certain that the page_url will return the expected result there as I never used the tag in such an article_list context.

Last edited by colak (2019-12-30 08:02:26)


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 2019-12-30 22:05:30

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: some ideas needed for txp 4.8 update

This looks achievable by treating distinctly Category1 and Category2 (untested). You might use Category1 for ‘normal’ tagging and Category2 for ‘category’ articles, and create the links this way:

<txp:if_article_category number="2">
    <txp:category2 link title />
<txp:else />
    <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
</txp:if_article_category>

To filter out ‘category’ articles when on a category page, set match="Category1" in <txp:article />.

Offline

#6 2019-12-31 05:52:39

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

Re: some ideas needed for txp 4.8 update

That is indeed a great idea as it will also help in not including articles residing in children categories. We are also planing to rename our ‘Events’ section to ‘Projects’ and work on the taxonomy of our site.

txp 4.8 will require a learning curve but the possibilities of the CMS look like they have been exponentially expanded. Big thanks to the devs!!!


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

Offline

#7 2020-01-01 06:56:52

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

Re: some ideas needed for txp 4.8 update

I have a couple more questions. I know it is new year’s day so no pressure:)

1. Are there any plans to introduce multiple categories and would this mean that the category 1/2 distinction will no longer work?

2. I can understand why two or more categories cannot share the same name when using some url schemas but this also sets some limitations when using the breadcrumb/article one.

With articles, we get a warning which we can ignore if the other article belongs to another section. Could this functionality be introduced for categories too or is there a conceptual or technical reason which makes it impossible?

Here is an example

/fruits/apples/granny-smith
/recipes/desserts/apples/apple-pie


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

Offline

#8 2020-01-01 10:08:57

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

Re: some ideas needed for txp 4.8 update

colak wrote #320776:

Are there any plans to introduce multiple categories

Yes… sort of. With tags. Current thinking is to repurpose keywords as proper tags since the keywords field is largely redundant, at least as it was originally implemented.

and would this mean that the category 1/2 distinction will no longer work?

Category1/2 will remain. No plans to change that as it’s too much upheaval.

Categories cannot have the same name because of the way they are stored internally in the database. Not sure how (if) we could bypass that.

Not sure I quite understand the issue with your examples, so forgive me for being dim:

/fruits/apples/granny-smith
fruits = section
apples = category1
granny-smith = category2? (or article?)
/recipes/desserts/apples/apple-pie
recipes= section
desserts = category1
apples = category2
apple-pie = article

You can assign categories to either cat1 or cat2 and they’ll appear in the correct order in the URL depending where they’re used. What am I missing?

Oh, and Happy New Year!


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

#9 2020-01-01 11:53:58

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

Re: some ideas needed for txp 4.8 update

Hmmm maybe you are right. I’ll do further testing and come back.


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

Offline

#10 2020-01-01 16:23:54

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

Re: some ideas needed for txp 4.8 update

Thought about it and Oleg’s idea above will not be as straight forward but I think that there is a solution.

Section landing page

Links to cat1 containing articles, and articles (not attached to categories) belonging to the section. Articles which have a cat2 are excluded. All articles having a cat2 will also have a cat1. There will be just one cat1 article/project that needs it.

url: site.tld/section/
real url: site.tld/projects/

Basic untested code which I am not sure that it will work.

<txp:if_article_category number="2">
<txp:hide>articles belonging to cat1 AND cat2, do NOT get listed</txp:hide>
    <txp:else />
        <txp:if_article_category number="1">
            <txp:category1 link title />
            <txp:hide>links if article belongs to cat1 but NOT to cat2</txp:hide>
        <txp:else />
            <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
            <txp:hide>links to articles NOT belonging to cat1 or cat2</txp:hide>
         </txp:if_article_category>
</txp:if_article_category>

category1 landing pages

They will contain one article and a side menu which will list article links that match cat1 articles and cat links containing articles belonging to cat2.

url: site.tld/section/cat1/
real url: site.tld/projects/project-name/

Basic untested code for side menu

<txp:article_custom break="li" wraptag="ul" section='<txp:section />' category='<txp:category1 />'>
    <txp:if_article_category number="2">
        <txp:category2 link title />
    <txp:else />
        <a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
    </txp:if_article_category>
</txp:article_custom>

category2 landing pages

They will contain one article and a side menu which will list the same links as the category1 landing pages

url: site.tld/section/cat1/cat2/
real url: site.tld/projects/project-name/exhibitions/

Individual articles belonging to categories

These pages will contain one article and a side menu which will list the same links as the category1 landing pages.

url: site.tld/section/cat1/cat2/article-title
real url: site.tld/projects/project-name/exhibitions/exhibition-title
real url: site.tld/projects/project-name/seminar/seminar-title
and/or
url: site.tld/section/cat1/article-title
real url: site.tld/projects/project-name/exhibition-title
real url: site.tld/projects/project-name/seminar-title

depending on the project.

Conclusion

The above draft expands the depth of the urls from a 2-dimentional structure (/section/title), to a 4-dimentional one /section/cat1/cat2/article-title. This is of course an 100% improvement and I think that it will be fully fulfil our current needs.

The sitemap will need to be updated to exclude the ids of articles which will be hosted in the /section/cat1/ and /section/cat1/cat2/ front end pages but the cat based urls will be included.

The reason for the previous comments is that I was thinking that by using subcategories, much of the above snippets could become shorter, sub-menus would be built based on parent category/ies, and it would increase the possibilities for deeper structures.

Further investigations

What I am not sure yet is how to determine the article which will be hosted in /section/cat1/cat2/ cases. A possibility would be sticky articles.
Also, I’m not sure if and how these articles which will be solely residing in category landing pages will be included in the rss feed.


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

Offline

#11 2020-01-03 19:07:06

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

Re: some ideas needed for txp 4.8 update

Bloke wrote #320781:

You can assign categories to either cat1 or cat2 and they’ll appear in the correct order in the URL depending where they’re used. What am I missing?

After further testing, the only way to get /section/cat1/cat2/... is by having sub categories. Both /breadcrumbs/title and section/category/title schemas return urls like site.tld/section/cat1+cat2/welcome-to-your-site and not the desired site.tld/section/cat1/cat2/welcome-to-your-site which signifies a deeper structure.

A note here that I think that both the schemas’ outputs are semantically correct.

This brings me back to the post above but I’m still hoping that there may be another way.

Rephrased here.

When saving an article which has the same title as another one in our db, we rightly get a warning which we can ignore if the other article’s title belongs to another section. Could this functionality be introduced for sub-categories too or is there a conceptual or technical reason which makes it impossible?

Here is an example based on my descriptions earlier in this post:

/fruits/apples/granny-smith <— /section/cat/title
/recipes/desserts/apples/apple-pie <— /section/ancestors/of/sub-cat/title

As is, there is no way to get our apple-pie as apples are already on the top of the category chain, and they can not also appear under the desserts.

Edited to add that I thought of a technical reason which only occurs in the messy schema where the category urls are so rudely not considering their ancestors: www.site.tld/index.php?s=recipes&c=apples

I would nevertheless still be interested to discuss a solution for this issue.

Last edited by colak (2020-01-03 19:58:36)


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

Offline

#12 2020-01-04 00:28:23

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

Re: some ideas needed for txp 4.8 update

colak wrote #320801:

Could this functionality be introduced for sub-categories too

We don’t have subcategories in Txp. We just have two categories that are siblings. Category 1 appears “first” in the list because, well, one of them has to! But it has no actual hierarchy so I’m not sure how we could detect if you’ve used it as such when you save. And even if we could, the number of times the same category is used across many articles, you’d be seeing the amber warning most of the time you saved.


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

Board footer

Powered by FluxBB