Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#13 2020-01-13 14:05:39

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

Re: contextual navigation

Yiannis, what is your working list-page code? There is no reason it wouldn’t be adaptable for individual pages.

And agree with Julian, separate category1/2 attributes would be handy.

Offline

#14 2020-01-13 14:46:24

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

Re: contextual navigation

Thanks again guys. here’s the article_list (simplified) working code. Apologies if any listforms are missing or they are there where they shouldn’t be.

<txp:if_article_list>

<txp:hide>==================-projects-======================</txp:hide>

<txp:if_section name='<txp:section />'>
<txp:hide>==================-search-======================</txp:hide>
<txp:if_search>
<txp:article pgonly="1" searchall="1" searchsticky="0" />
<txp:if_search_results>
<h3>You searched for <strong><txp:page_url type="q" /></strong>. <txp:search_result_count />.</h3>
<txp:else />
</txp:if_search_results>
<txp:article limit="999" searchall="1" />
<txp:else />


<txp:variable name="cat1" value='txp:page_url type="2" />' /> 
<txp:variable name="cat2" value='<txp:page_url type="3" />' />

<txp:hide>==================-category 1-======================</txp:hide>

<txp:if_category number="1">
<txp:if_variable name="cat2" value="">
<txp:article status limit="30" listform="list_cat2_projects" form="" c10="" />
<txp:else />

<txp:hide>==================-Category 2-======================</txp:hide>

<txp:article_custom limit="1" status listform="" form="">
<txp:if_article_category number="2">
<a href="/<txp:section />/<txp:category1 />/"><txp:category1 /></a> 
</txp:if_article_category>
</txp:article_custom>
<txp:article limit="999" match="Category1=2, Category2=3" form="list_cat_projects" c10="y" />
</txp:if_variable>

<txp:else />

<txp:hide>==================-section landing page-======================</txp:hide>

<txp:article_custom status section="projects" c10="x" form="" limit="999">
<txp:if_article_category>
<a rel="follow" href="/<txp:section />/<txp:category1 />/"><txp:title /></a>
<txp:else />
<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
</txp:if_article_category>
</txp:article_custom>

</txp:if_category>
</txp:if_search>
</txp:if_section>

</txp:if_article_list>

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

Offline

#15 2020-01-13 16:10:48

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

Re: contextual navigation

Here is my latest effort, based on the working article lists code. It returns the same list (when I view a cat1 or cat1+cat2 articles) as the list generated when I am viewing an article in the section which does not belong to any category.

<txp:variable name="cat1" value='<txp:page_url type="2" />' /> 
<txp:variable name="cat2" value='<txp:page_url type="3" />' />
<txp:hide>==================-category 1-======================</txp:hide>

<txp:if_category number="1">
<txp:if_variable name="cat2" value="">
<txp:related_articles status limit="30" listform="" form="" c10="">
<txp:if_custom_field name="status" value="5">
<a href="/<txp:section />/<txp:category1 />/<txp:category2 />/" rel="bookmark"><txp:title /></a>
<txp:else />
<h3><a href="<txp:permlink />" rel="bookmark"><txp:title /></a></h3>
</txp:if_custom_field>
</txp:related_articles>

<txp:else />

<txp:hide>==================-Category 2-======================</txp:hide>

<txp:article_custom limit="1" status listform="" form="">
<txp:if_article_category number="2">
<a href="/<txp:section />/<txp:category1 />/"><txp:category1 /></a> 
</txp:if_article_category>
</txp:article_custom>
<txp:article_custom limit="999" match="Category1=2, Category2=3" form="" c10="y" label='Other <txp:category1 /> <txp:section />' labeltag="h4">
<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
</txp:article_custom>
</txp:if_variable>

<txp:else />

<txp:hide>==================-section landing page-======================</txp:hide>

<txp:article_custom status section='<txp:section />' c10="x" form="" limit="999" wraptag="ul" break="li" label='Other <txp:section />' labeltag="h4">
<txp:if_article_category>
<a rel="follow" href="/<txp:section />/<txp:category1 />/"><txp:title /></a>
<txp:else />
<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
</txp:if_article_category>
</txp:article_custom>

</txp:if_category>

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

Offline

#16 2020-01-13 16:31:45

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

Re: contextual navigation

I just uploaded the particular page I am working on as well as the related forms on github. Note that for the listform above, I only uploaded the partially working version which lists the correct articles when the article only belongs to one category, and when it has no categories at all.


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

Offline

#17 2020-01-13 16:55:42

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

Re: contextual navigation

I’ve just committed a tweak to enable finer filtering:

<!-- no categories -->
<txp:article_custom exclude="category" />

<!-- Category1 without Category2 -->
<txp:article_custom category='<txp:category1 />' match="Category1" exclude="Category2" />

<!-- matching both categories from URL -->
<txp:article_custom match="Category1=2, Category2=3" />

Something like this should work on individual pages in section/category scheme, please test:

<txp:if_article_category number="1">
	<txp:if_article_category number="2">
		<txp:article_custom section match="Category1=2, Category2=3" form="article_listing" />
	<txp:else />
		<txp:article_custom section match="Category1=2" exclude="Category2" form="article_listing" />
	</txp:if_article_category>
<txp:else />
	<txp:article_custom section exclude="category" form="article_listing" />
</txp:if_article_category>

Offline

#18 2020-01-13 18:18:28

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

Re: contextual navigation

Niiice! That’s super slick. I presume this’ll make the custom-fields branch merge, umm, interesting though, hehe. I daren’t try it :)


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

#19 2020-01-13 18:44:51

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

Re: contextual navigation

Thanks so much Oleg. Your tweaks and suggestion work just fine with a minor issue when viewing Cat1-only articles. I overcame this easily by using the traditional syntax. I could have used a related_articles tag there but I think that keeping an unlinked title helps with the positioning of the article during surfing. Here is what it absolutely appears to be the working code including some niche parameters I have introduced.

<txp:if_article_category number="1">
	<txp:if_article_category number="2">
		<txp:article_custom section match="Category1=2, Category2=3" form="" listform="" c10="y" wraptag="ul" break="li" label='Other <txp:category1 /> <txp:section />' labeltag="h4" class="submenu" limit="999">
			<txp:if_article_id>
				<span><txp:title /></span>
			<txp:else />
				<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
			</txp:if_article_id>
		</txp:article_custom>
	<txp:else />
		<txp:article_custom label='Other <txp:category1 /> <txp:section />' labeltag="h4" section='<txp:section />' category='<txp:category1 />' form="" listform="" limit="100" wraptag="ul" break="li" class="submenu">
			<txp:if_article_id>
				<span><txp:title /></span>
			<txp:else />
				<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
			</txp:if_article_id>
		</txp:article_custom>
	</txp:if_article_category>
<txp:else />
	<txp:article_custom status section form="" listform="" label='Other <txp:section />' labeltag="h4" limit="999" wraptag="ul" break="li" c10="x" class="submenu">
		<txp:if_article_category>
			<txp:if_custom_field name="status" value="5">
				<a href="/<txp:section />/<txp:category1 />/" rel="follow"><txp:title /></a>
			</txp:if_custom_field>
		<txp:else />
			<txp:if_article_id>
				<span><txp:title /></span>
			<txp:else />
				<a href="<txp:permlink />" rel="bookmark"><txp:title /></a>
			</txp:if_article_id>
		</txp:if_article_category>
	</txp:article_custom>
</txp:if_article_category>

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

Offline

#20 2020-01-13 19:05:26

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

Re: contextual navigation

Bloke wrote #321069:

Niiice! That’s super slick. I presume this’ll make the custom-fields branch merge, umm, interesting though, hehe. I daren’t try it :)

Just saw your post:) It is a beauty. I found that I needed the CFs as I created some faux landing pages in order to parse some info from the articles’ CFs but also to place those links on the correct spot of the timeline.

This update requires a learning curve for me but I enjoy witnessing the flexibility of txp surpassing another level.


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

Offline

#21 2020-01-13 21:52:27

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,578
Website

Re: contextual navigation

etc wrote #321068:

I’ve just committed a tweak to enable finer filtering…

Bloke wrote #321069:

Niiice! That’s super slick.

Agree! Ever more flexibility. And what a tweak: just three characters changed around. Wow!


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB