Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2010-09-25 12:08:07

amavai
Member
Registered: 2009-08-25
Posts: 37

Offset sorting question

Hi Forum!

Hope someone can help.. after reading a lot of articles here and out this forum, I can’t find a solutions for the offset attribute..

here is the code for my blog section:

<txp:if_individual_article>
<txp:output_form form="indiv-post" limit="1" section="blog" pageby="5"/>
<div id="post-b">
<txp:article_custom form="custom_3" limit="1" offset="1" section="blog" pageby="5" />
</div>
<txp:else />
<txp:article form="custom_1" limit="1" />
<div id="post-b">
<rsx_page_number />
<txp:article form="custom_2" limit="1" offset="2" />
<rsx_page_number />
</div>
</txp:if_individual_article>

Indiv-post: is the permanent link for the main article
Custom 3 is a list of articles related for the same section(blog)

In the else part:

custom_1 sort by category
custom_2 sort by category

These are regarding the style, the first one is bigger than the others. They are sort by category ( big-post and small post) both on the same section, blog.

The problem is on the individual article. Its works fine, but on the div “post-b” the article coming from indv-post appear on the list, so appear twice.

Here is the code for the main problem:

<txp:output_form form="indiv-post" limit="1" section="blog" pageby="5"/>
<div id="post-b">
<txp:article_custom form="custom_3" limit="1" offset="1" section="blog" pageby="5" />
</div>

Any ideas?

Thanks!

Amavai

(added bc. for better code display. -Els)

Last edited by els (2010-09-26 14:56:16)

Offline

#2 2010-09-25 12:23:28

thebombsite
Archived Plugin Author
From: Exmouth, England
Registered: 2004-08-24
Posts: 3,251
Website

Re: Offset sorting question

Well I’m not sure that this will solve your problem but you can’t use the “pageby” attribute with the <txp:article_custom /> tag nor are there any attributes for the <txp:output_form /> tag other than “form”.

I would also need to see the code for your “indiv-post” form template.

Last edited by thebombsite (2010-09-25 12:33:04)


Stuart

In a Time of Universal Deceit
Telling the Truth is Revolutionary.

Offline

#3 2010-09-25 17:03:59

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Offset sorting question

That is, article_custom doesn’t support pagination. Assuming this is a development site, put it in debugging mode so you can see the errors such as those Stuart mentions.


Code is topiary

Offline

#4 2010-09-26 14:59:24

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

Re: Offset sorting question

I guess if you change both the output_form and article_custom tags to plain article tags, it should work fine.

Offline

#5 2010-09-26 18:16:32

amavai
Member
Registered: 2009-08-25
Posts: 37

Re: Offset sorting question

Hi,

First of all, many thanks for your responses!

I have tried Els solutions but I still have the problem. Or worst, now my individual article page, is repeating the article twice and is not showing the rest of the article for the same category ( blog)

This is what I make:

<txp:if_individual_article>
<txp:article form="cus-indiv" limit="1" section="blog" />
<div id="post-b">
<txp:article form="group-indiv" limit="5" offset="1" section="blog" />
</div>
<txp:else />
<txp:article form="custom_1" limit="1" />
<div id="post-b">
<rsx_page_number />
<txp:article form="custom_2" limit="1" offset="2" />
<rsx_page_number />
</div>
</txp:if_individual_article>

And the forms are:
cust-indiv:

<h1><a href="<txp:permlink />"><txp:title /></a></h1>
<h5>Publicado por <txp:author/> el <txp:posted /></h5>
<a href="<txp:permlink />"><txp:article_image /></a>
<txp:body />
<h2><b>Etiquetas:</b> <txp:tru_tags_if_has_tags>
  <txp:tru_tags_from_article />
</txp:tru_tags_if_has_tags></h2>

group-indiv:

<div class="p-secoblog">
<txp:article_image thumbnail="1" />
<h4><a href="<txp:permlink />"><txp:title /></a></h4>
<txp:rss_auto_excerpt words="20" overrideexcerpt="1" linktext=" " />
</div>

I think that I have a form problem, because now each form when is render appear with the legend at the end “Commenting is closed for the article”
I can’t find where is coming this legend! unfortunately..

Hope that this clarify! many thanks again

Amavai

Last edited by amavai (2010-09-26 18:23:57)

Offline

#6 2010-09-26 19:20:42

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

Re: Offset sorting question

I realize my advice was wrong. The <txp:article /> tag is context sensitive, which means that in individual article context it will only output that individual article. For your article list on the individual article page you therefore need <txp:article_custom />. For the same reason you can remove the limit and section attributes from the individual article tag. Try this:

<txp:if_individual_article>
	<txp:article form="cus-indiv" />
	<div id="post-b">
	<txp:article_custom form="group-indiv" limit="5" offset="1" section="blog" />
	</div>
<txp:else />
	<txp:article form="custom_1" limit="1" />
	<div id="post-b">
	<rsx_page_number />
	<txp:article form="custom_2" limit="1" offset="2" />
	<rsx_page_number />
	</div>
</txp:if_individual_article>

I think that I have a form problem, because now each form when is render appear with the legend at the end “Commenting is closed for the article”

In Preferences, set Automatically append comments to articles to ‘No’.

Offline

#7 2010-09-28 16:07:35

amavai
Member
Registered: 2009-08-25
Posts: 37

Re: Offset sorting question

Hi !

The code is working but repeating.. I am playing around some time , make use of the txp:article instead of article_custom, as well with output_form, offset=“1” inside and outside the form and I still have the problem..

<txp:if_individual_article>
    <txp:article form="cus-indiv"  />
    <div id="post-b">
	<txp:article form="custom_3" offset="1" />
    </div>
<txp:else />
  </code>
</txp:if_individual_article>

form custom_3:

<txp:article_custom form="second-post-model" section="blog" limit="3"   />

Form: cus-indiv

<h1><a href="<txp:permlink />"><txp:title /></a></h1>
 <h5>Publicado por <txp:author/> el <txp:posted /></h5>
<a href="<txp:permlink />"><txp:article_image /></a>
<txp:body />
<h2><b>Etiquetas:</b> <txp:tru_tags_if_has_tags>
  <txp:tru_tags_from_article />
</txp:tru_tags_if_has_tags></h2>

Any ideas? How can make txp know that we are talking about an article in a list? somebody know how to work with article_list or similar? Thank you very much in advance!

Last edited by amavai (2010-09-28 16:12:46)

Offline

#8 2010-09-28 16:23:19

jsoo
Plugin Author
From: NC, USA
Registered: 2004-11-15
Posts: 1,793
Website

Re: Offset sorting question

if_article_list and if_individual_article are opposites.

<txp:if_individual_article>
    Foo
<txp:else />
    Bar
</txp:if_individual_article>

gives exactly the same result as

<txp:if_article_list>
    Bar
<txp:else />
    Foo
</txp:if_article_list>

Looks as though you just need to move the <txp:else /> up a few lines.


Code is topiary

Offline

#9 2010-09-28 16:35:35

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

Re: Offset sorting question

amavai wrote:

<txp:if_individual_article>
    <txp:article form="cus-indiv"  />
    <div id="post-b">
	<txp:article form="custom_3" offset="1" />
    </div>
<txp:else />
  </code>
</txp:if_individual_article>

Again: the article tag is context sensitive. If you have two article tags inside if_individual_article, you’ll get the same individual article twice. The second one should be article_custom. If I were you I’d try and replace the second article tag with the tag you now have in form custom_3:

<txp:article_custom form="second-post-model" section="blog" limit="3"   />

So like this:

<txp:if_individual_article>
    <txp:article form="cus-indiv"  />
    <div id="post-b">
	<txp:article_custom form="second-post-model" section="blog" limit="3"   />
    </div>
<txp:else />
  // code for article list page goes here
</txp:if_individual_article>

It doesn’t really make sense to have (only) an article_custom tag in a form that is called by an article_custom tag…
And remove the </code>, or is it just an example??

Last edited by els (2010-09-28 16:36:08)

Offline

#10 2010-09-28 17:15:16

amavai
Member
Registered: 2009-08-25
Posts: 37

Re: Offset sorting question

Hi,

Could be the possibility that the attribute offset is displaying the most recent article viewed instead a list of articles in the normal flow? ( sort by section=blog, all the articles are in this section)

I just put the tag </code>because the main interface of the blog is working fine. I have two models, one big with 2 articles and 3 small. They are sort by category ( i have two, big-post and small-post, all under section blog)

So the problem is when the application is working on the individual article context. The article display fine, but the “archieve” are not taking out the current individual article.

Here are all the forms involved:

<txp:if_individual_article>
	<txp:article form="cus-indiv" />
<div id="post-b">
<txp:article_custom form="second-post-model" limit="3" offset="1" section="blog" />
</div>
<txp:else />
<txp:article form="custom_1" limit="1"/>
<div id="post-b">
<txp:article form="custom_2" limit="1" />
</div>
</txp:if_individual_article>

Form second-post-model:

<div class="p-secoblog">
<txp:article_image thumbnail="1" />
<h4><a href="<txp:permlink />"><txp:title /></a></h4>
<txp:rss_auto_excerpt words="20" overrideexcerpt="1" wraptag="p" linktext=" " />
</div>

Form custom_1:

<txp:article_custom form="main-post-model" category="big-post" limit="2" />
Form main-post-model:
< div class="ins-blog">
<h1><a href="<txp:permlink />"><txp:title /></a></h1>
<h5>Publicado por <txp:author/> el <txp:posted /></h5>
<a href="<txp:permlink />"><txp:article_image /></a>
<txp:rss_auto_excerpt words="45" overrideexcerpt="1" linktext="Seguir leyendo &raquo;" />
<h2><b>Etiquetas:</b> <txp:tru_tags_if_has_tags>
  <txp:tru_tags_from_article />
</txp:tru_tags_if_has_tags></h2>
</div>

Form custom_2:

<txp:article_custom form="second-post-model" category="small-post" limit="3"  />

Form secod-post-model:

<div class="p-secoblog">
<txp:article_image thumbnail="1" />
<h4><a href="<txp:permlink />"><txp:title /></a></h4>
<txp:rss_auto_excerpt words="20" overrideexcerpt="1" wraptag="p" linktext=" " />
</div>

Form cus-indiv:

<h1><a href="<txp:permlink />"><txp:title /></a></h1>
<h5>Publicado por <txp:author/> el <txp:posted /></h5>
<a href="<txp:permlink />"><txp:article_image /></a>
<txp:body />
<h2><b>Etiquetas:</b> <txp:tru_tags_if_has_tags>
  <txp:tru_tags_from_article />
</txp:tru_tags_if_has_tags></h2>

I probably have some extra forms, one inside the other, but this is because the pagination. As far as I understood, Its better to make a pagination with txp:article instead article_custom. But in terms of functionality, I need to sort my articles per Category on the main page, and per section ( the general one) in the individual article page.

Please, take a look if you want to the project live: http://www.allin-energy.com/blog/ to see it in action, probably will clarify.

Many thanks again!

Last edited by amavai (2010-09-28 17:28:45)

Offline

#11 2010-09-28 19:44:08

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

Re: Offset sorting question

amavai wrote:

So the problem is when the application is working on the individual article context. The article display fine, but the “archieve” are not taking out the current individual article.

Ah, is that what you want to do with offset="1"? You are right that this attribute only skips the first article in the specified sort order, which in this case is the default: posted desc.

Try this in your form ‘second-post-model’ (and remove the offset="1" from the article_custom tag):

<txp:if_individual_article><txp:if_article_id id='<txp:article_id />'>
<txp:else />
<div class="p-secoblog">
<txp:article_image thumbnail="1" />
<h4><a href="<txp:permlink />"><txp:title /></a></h4>
<txp:rss_auto_excerpt words="20" overrideexcerpt="1" wraptag="p" linktext=" " />
</div>
</txp:if_article_id></txp:if_individual_article>

I’m not 100% sure you need the extra if_individual_article tags there, you’ll need to test if leaving them out works as well.

Last edited by els (2010-09-28 19:44:32)

Offline

#12 2010-09-29 12:31:26

amavai
Member
Registered: 2009-08-25
Posts: 37

Re: Offset sorting question

Hi Els,

Many thanks for your response, but unfortunately it doesn’t work.. When I try to use your suggestion about the if_article_id it doesn’t display the entire list ( also checked with your quotes ‘ ‘ and the others “ “)

If_individual_article display the same result as before, with the current article displaying twice on the list.. I have read something about chh_article plugin but I cant download it because is not supported any more..

Do you have this plugin code available? or is some plugin that can achieve this request? I have also try with some Stef’s plugin like variables, etc, but no case..

Do you know some way to make this offset attribute works?

Many thanks again!

Offline

Board footer

Powered by FluxBB