Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-04-18 19:11:04
- Rexel
- Member
- Registered: 2005-11-18
- Posts: 26
if_section name="default" dont mess up the rest
I have the code below that I’ve been batteling with for a while, it works ok until I hit search or select a category.
<code>
<txp:if_search>
<txp:article form=“search_results” limit=“50” pgonly=“1” />
<txp:search_count />
</txp:if_search>
</code>
<code>
<txp:if_category>
<txp:article form=“art_dif” listform=“excerpt” />
</txp:if_category>
</code>
<code>
<txp:if_section name=”,home”>
<txp:article form=“static_article” limit=“1” status=“sticky” />
<txp:article form=“art_dif” listform=“excerpt” limit=“1” status=“live” />
</txp:if_section>
</code>
<code>
<txp:if_section name=“services,about,contact”>
<txp:article form=“static_article” />
</txp:if_section>
</code>
<code>
<txp:if_section name=“work”>
<txp:article form=“work_sample” listform=“work_sample_excerpt” />
</txp:if_section>
</code>
<code>
<txp:if_section name=“journal”>
<txp:article form=“art_dif” listform=“excerpt” limit=“10” />
<txp:if_article_list>
<txp:older>Older</txp:older> | <txp:newer>Newer</txp:newer>
</txp:if_article_list>
<txp:if_individual_article>
<txp:link_to_prev>Previous</txp:link_to_prev> | <txp:link_to_next>Next</txp:link_to_next>
</txp:if_individual_article>
</txp:if_section>
</code>
Visiting the home page I see two static “sticky“articles and 1 “latest journal entry” live article, just what I wanted.
The rest of the pages display as I intended aswell.
But when I select a gategory, I see a list of article belonging to it (what I expected), but the first one in the list is repeated at the end of the list.
Another behaviour is that the search results page show up my 2 sticky articles at the begining of the page.
I have to admit that I don’t (fully) understand Txp logic yet, but I think the default page is were its all happening, giving that the search result and the category are not sections themselfs hense the <code>if_section</code> statment is executed, don’t find a section name and it output the sticky articles in the case of search result and double up one article in the category case.
Then again maybe the above is wrong and I’m just not getting it yet.(defenitly something I’m not getting anyway)
Thats why I’m hoping if you guys can help shed some light on this.
Oh.. just one last thing, the section called home should have the same output as the default section, = 2 sticky articles and one live article, but when I type mysite/home I see only the 2 sticky artices, no live article. So if a visiter come from a serach engine with the url mysite/home he/she will not see the same as in the url mysite. Thats another thing I’m trying to figure out.
Any idea how to go about fixing all this. I can’t drink anymore coffee
Offline
#2 2006-04-18 23:56:48
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: if_section name="default" dont mess up the rest
Try this:
<txp:if_search>
<txp:article limit="50" pgonly=1 /><txp:search_count />
<txp:article limit="50" form="search_results" />
<txp:else />
<txp:if_category>
<txp:article form="art_dif" listform="excerpt" />
</txp:if_category>
<txp:if_section name=",home">
<txp:article status="sticky" limit="1" form="static_article" />
<txp:article status="live" limit="1" form="art_dif" listform="excerpt" />
</txp:if_section>
<txp:if_section name="services,about,contact">
<txp:article form="static_article" />
</txp:if_section>
<txp:if_section name="work">
<txp:article form="work_sample" listform="work_sample_excerpt" />
</txp:if_section>
<txp:if_section name="journal">
<txp:article limit="10" form="art_dif" listform="excerpt" />
<txp:if_article_list>
<txp:older>Older</txp:older> | <txp:newer>Newer</txp:newer>
<txp:else />
<txp:link_to_prev>Previous</txp:link_to_prev> | <txp:link_to_next>Next</txp:link_to_next>
</txp:if_article_list>
</txp:if_section>
</txp:if_search>
?
Offline
Re: if_section name="default" dont mess up the rest
Hi Rexel,
it’s very probably that I dont have all the answers for you, but…
First: category view and search results use the “default” section/page template. That’s the first problem with your snippet.
So, when you are viewing a category or a search result, you are on “default” section and this part of your snippet:
<code><txp:if_section name=”,home”>
<txp:article form=“static_article” limit=“1” status=“sticky” />
<txp:article form=“art_dif” listform=“excerpt” limit=“1” status=“live” />
</txp:if_section></code>
is still being parsed (because, again, you are in “default” section).
Maybe, you want something like this:
<code><txp:if_section name=”,home”>
<txp:if_search>
<txp:article form=“search_results” limit=“50” pgonly=“1” />
<txp:search_count />
<txp:else />
<txp:if_category>
<txp:article form=“art_dif” listform=“excerpt” />
<txp:else />
<txp:article form=“static_article” limit=“1” status=“sticky” />
<txp:article form=“art_dif” listform=“excerpt” limit=“1” status=“live” />
</txp:if_category>
</txp:if_search>
</txp:if_section></code>
Translated to words: “if we are in section “default” or “home”, check if we are in a search result page. If yes, output the search result. Else, check if we are in a category. If yes, output an article list. Else (if we are not in a search nor a category), output the sticky and the live article…”
Other solutions:
Make a category listing use the same section and template by thebombsite
Using search in Textpattern by zem.
Finally, I think that if you dont add any link that point to /home/, search engines wont index that URL.
You are not getting the “live” article in your /home/ url because it’s very probably that the “live” article belongs to another section, and the reason why it appears in the mysite/ url is because the “default” section display articles from sections that are configured to “Show in frontpage” (Presentation -> Sections).
But there is not reason for that “live” article to display in the /home/ section because it belongs to another section.
Ufffff, I dont know if what I’m saying makes sense to you.
I hope this help you anyway (to hear the “clic” in your head).
Offline
#4 2006-04-19 23:40:27
- Rexel
- Member
- Registered: 2005-11-18
- Posts: 26
Re: if_section name="default" dont mess up the rest
Sorry about my late reply.
Problem solved.
Thank you mary.
Your solution solved the search result page but not the category listing, double post were still showing.
Thank you maniqui.
Your solution solved the category but not the search result, no results were showing at all.
So a combination of both did the trick.
Here’s the final block of code:for the home/default section only
<code>
<txp:if_section name=”,home”>
<txp:if_search>
<txp:article limit=“50” pgonly=1 /><txp:search_count />
<txp:article limit=“50” form=“search_results” />
<txp:search_count />
<txp:else />
<txp:if_category>
<txp:article form=“art_dif” listform=“excerpt” />
<txp:else />
<txp:article form=“static_article” limit=“1” status=“sticky” />
<txp:article form=“art_dif” listform=“excerpt” limit=“1” status=“live” />
</txp:if_category>
</txp:if_search>
</txp:if_section>
</code>
Regarding the home section listing in search engine, I think it dose get indexed, maybe not siteURL/home but siteURL/home/article will, just like siteURL/blog/article do.
So if there is an article in home section like a welcome text (a sticky article in this case), it will get indexed.
I was typing mysiteURL/home myself just to see what happen even if the home section will be represented by the default section anyway as it has (show in front page) selected in prefs. But I expected the home and default section to have the same output, ie: 2 sticky articles and one live article. There are no live article shown in the home section. So if a visiter comes from a search engine with the url siteURL/home he/she will not see the same as the url siteURL which technicaly should be the same.
Offline
Re: if_section name="default" dont mess up the rest
Rexel wrote:
Regarding the home section listing in search engine, I think it dose get indexed, maybe not siteURL/home but siteURL/home/article will, just like siteURL/blog/article do.
So if there is an article in home section like a welcome text (a sticky article in this case), it will get indexed.
Yes, but I think indexation will only happen if the “welcome text” sticky article has a link to itself (= a permlink to the individual-article).
Usually, “welcome text” is just static content that doesnt need to be linked to a permlink url. You just want it to be in your home page as a hard-coded text.
Another option is to have your static text not as an article but as a form (in Presentations -> Form).
But I expected the home and default section to have the same output, ie: 2 sticky articles and one live article. There are no live article shown in the home section. So if a visiter comes from a search engine with the url siteURL/home he/she will not see the same as the url siteURL which technicaly should be the same.
Yes, I understand. But /home/ section will only display live articles that belongs to it. siteURL (“default” section) displays live articles for any section that has the “show in frontpage” option setted to “yes”.
Offline
#6 2006-04-21 00:32:20
- Rexel
- Member
- Registered: 2005-11-18
- Posts: 26
Re: if_section name="default" dont mess up the rest
I get it now.
Thanks again maniqui.
I think the idea of having the welcome text as a form then output it with <txp:output_form form="myform" />
rather than a sticky article make sense and is much better.
Never though of that.
Long way to go to know it all.
If indextation don’t happen if there are no permenant link in the article then that solves my imaginary problem.
Thanks again.
Offline