Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2011-08-27 05:03:32

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

[SOLVED] template structure

I am working on my localhost. This should be simple enough but I just can’t figure it out!

I am trying to create a template where I can have

  • search results
  • a particular article in the section front page
  • a list of articles when in a category url
  • an article when in an individual article page

The skeletal code below is where I am at the moment but it does not work as it does not return the expected content when visiting the particular urls.

Can anybody figure out where I am messing it up?

<txp:if_search>
	<txp:if_search_results>
		<txp:article searchsticky="1">
			<h2><txp:permlink><txp:title /></txp:permlink></h2>
		</txp:article>
	<txp:else />
		<p>No results</p>
	</txp:if_search_results>
	<txp:else />
		<txp:if_article_list>
			<txp:if_section name='<txp:section />'>
				<txp:article_custom id="2" status="sticky">
					<h2><txp:title /></h2>
					<txp:body />
				</txp:article_custom>
				<txp:else />
				<txp:if_category name='<txp:category />'>
					<txp:article_custom section='<txp:section />' category='<txp:category />' limit="999" time="any">
					<h2><txp:permlink><txp:title /></txp:permlink></h2>
					</txp:article_custom>
				</txp:if_category>
			</txp:if_section>
		<txp:else />
			<txp:article>
				<h2><txp:title /></h2>
				<txp:body />
			</txp:article>
		</txp:if_article_list>
</txp:if_search>

Last edited by colak (2011-08-27 13:30:18)


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 2011-08-27 11:22:20

tumain
Member
From: UK
Registered: 2011-07-29
Posts: 12
Website

Re: [SOLVED] template structure

Hmm… Perhaps its because you don’t have a closing </txp:if_category>.

If it helps, this is one I recently did for my own website.

<txp:output_form form="meta" />
<body id="<txp:if_section name="">front<txp:else /><txp:section /></txp:if_section>">

	<div class="grid">
		<!-- header -->
		<txp:output_form form="head" />

		<!-- if category listing -->
		<txp:if_category>
			<txp:output_form form="category_listing" />

			<!-- if individual article change navigation at bottom (i.e. older posts, newer posts) -->
			<txp:if_individual_article>
				<txp:output_form form="nav-article" />
			<txp:else />
				<txp:output_form form="pagination" />
			</txp:if_individual_article>

			</div>
			<txp:output_form form="foot-wide" />

		<txp:else />

			<!-- if search results -->
			<txp:if_search>

				<txp:output_form form="search_listing" />

				<!-- if individual article change navigation at bottom (i.e. older posts, newer posts) -->
				<txp:if_individual_article>
					<txp:output_form form="nav-article" />
				<txp:else />
					<txp:output_form form="pagination" />
				</txp:if_individual_article>

				</div>
				<txp:output_form form="foot-wide" />

			<txp:else />

				<!-- not category listing or search page? show home page -->
				<txp:output_form form="homepage" />

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

</body>
</html>

Last edited by tumain (2011-08-27 11:25:06)

Offline

#3 2011-08-27 13:32:28

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

Re: [SOLVED] template structure

thank you Justin, It kind of move things on. I can now see article id 2 no matter what url I’m in.

Updated the code above to include the if_category closing tag.


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 2011-08-27 14:11:25

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [SOLVED] template structure

Hi Yiannis, try this:

<txp:if_search><!-- search results page -->
	<txp:if_search_results><!-- search results page with results -->
		<txp:article searchsticky="1">
			<h2><txp:permlink><txp:title /></txp:permlink></h2>
		</txp:article>
	<txp:else /><!-- search results page with no results -->
		<p>No results</p>
	</txp:if_search_results>
<txp:else /><!-- anything but a search results page -->
	<txp:if_article_list><!-- article list page, either section or category -->
		<txp:if_category><!-- category page -->
			<txp:article_custom section='<txp:section />' category='<txp:category />' limit="999" time="any">
				<h2><txp:permlink><txp:title /></txp:permlink></h2>
			</txp:article_custom>
		<txp:else /><!-- section home page -->
			<txp:article_custom id="2" status="sticky">
				<h2><txp:title /></h2>
				<txp:body />
			</txp:article_custom>
		</txp:if_category>
	<txp:else /><!-- individual article page -->
		<txp:article>
			<h2><txp:title /></h2>
			<txp:body />
		</txp:article>
	</txp:if_article_list>
</txp:if_search>

Edit: instead of <txp:article_custom section='<txp:section />' category='<txp:category />'> you can use <txp:article>.

Last edited by els (2011-08-27 14:13:11)

Offline

#5 2011-08-27 14:45:39

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

Re: [SOLVED] template structure

Hi Els
I tried your suggestion but unfortunately it produces the same results. Just shows article id 2.


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

Offline

#6 2011-08-27 15:07:33

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [SOLVED] template structure

colak wrote:

I tried your suggestion but unfortunately it produces the same results. Just shows article id 2.

Then all of us must be sleeping… ;) Can you post a tag trace of the pages that unintentionally show article #2?

Last edited by els (2011-08-27 15:09:02)

Offline

#7 2011-08-27 15:25:32

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

Re: [SOLVED] template structure

Here is a category page which is obviously returning a faux false.

<txp:if_search>
	[<txp:if_search>: false]
	<txp:if_article_list>
		[<txp:if_article_list>: true]
		<txp:if_category>
			[<txp:if_category>: false]
			<txp:article_custom id="2" status="sticky">
				[SQL (0.0011699199676514): select *, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod from aa_textpattern as textpattern where 1=1 and Status >= 4 and Posted <= now() and ID IN (2) order by Posted desc limit 0, 10]
				[article 2]
				<txp:title />
				<txp:body />
			</txp:article_custom>
		</txp:if_category>
	</txp:if_article_list>
</txp:if_search>

I also tried replacing <txp:if_category> with <txp:if_category name='<txp:category />'>, which again returns a false:(

Last edited by colak (2011-08-27 15:30:47)


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 2011-08-27 15:32:46

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [SOLVED] template structure

I suddenly remember there is an issue with if_category and some plugins. Are you using gbp_permanent_links?

Offline

#9 2011-08-27 15:36:46

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

Re: [SOLVED] template structure

Els wrote:

I suddenly remember there is an issue with if_category and some plugins. Are you using gbp_permanent_links?

!!! yep:) For the first time I’m experimenting with it. Is that it? Is there a work around?


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 2011-08-27 15:49:19

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [SOLVED] template structure

colak wrote:

Is there a work around?

Fortunately, yes :) Replace this:

		<txp:if_category><!-- category page -->
			<txp:article_custom section='<txp:section />' category='<txp:category />' limit="999" time="any">
				<h2><txp:permlink><txp:title /></txp:permlink></h2>
			</txp:article_custom>
		<txp:else /><!-- section home page -->
			<txp:article_custom id="2" status="sticky">
				<h2><txp:title /></h2>
				<txp:body />
			</txp:article_custom>
		</txp:if_category>

with this:

		<txp:variable name="categoryname" value='<txp:page_url type="c" />' />
		<txp:if_variable name="categoryname" value=""><!-- section home page -->
			<txp:article_custom id="2" status="sticky">
				<h2><txp:title /></h2>
				<txp:body />
			</txp:article_custom>
		<txp:else /><!-- category page -->
			<txp:article_custom section='<txp:section />' category='<txp:category />' limit="999" time="any">
				<h2><txp:permlink><txp:title /></txp:permlink></h2>
			</txp:article_custom>
		</txp:if_variable>

Offline

#11 2011-08-27 16:43:56

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

Re: [SOLVED] template structure

That did it. The ever flexible txp:variable from the code queen. Thanks soo much Els.

I’m actually experimenting on a trilingual site without the use of Steve’s plugin. Hopefully i’ll be able to work out the rest of it:)


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 2011-08-27 21:27:58

els
Moderator
From: The Netherlands
Registered: 2004-06-06
Posts: 7,458

Re: [SOLVED] template structure

colak wrote:

I’m actually experimenting on a trilingual site without the use of Steve’s plugin.

I did one years ago. Not as sophisticated as an MLP site, but quite workable.

Hopefully i’ll be able to work out the rest of it:)

I’m sure you will. Let me know when it’s finished, I’d love to see how you did it.

Offline

Board footer

Powered by FluxBB