Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2020-08-30 00:46:02

Myusername
Member
Registered: 2019-12-12
Posts: 162

Loop with articles from two sites ordered by date

Good night people! I haven’t been to the forum in a while, I hope you are all well.

So, I have a website created in textpattern where I did a new installation of Textpattern in a subdirectory. I used the same database with a table prefix as requested in the installation. Everything went well.

Now, I want to make a loop that contains the articles from the main site and also from the site that is in the subdirectory and then sort by the most recent ones. I did all this with the etc_query plug-in like this:

<txp:variable name='loopoffset' value='0'/>
<txp:variable name='looplimit' value='5'/>
.
<txp:etc_query globals='variable' data="SELECT * FROM textpattern WHERE Status = '4' UNION ALL SELECT * FROM elctextpattern WHERE Status = '4' ORDER BY Posted desc LIMIT {?looplimit} OFFSET {?loopoffset}">
   <h1>{Title?}</h1>
   <p>{Posted?}</p>
<txp:else />
   <p>Nobody here.</p>
</txp:etc_query>

Ok, work completed so far, the problem arises when I need a pagination for the next articles and I’m not sure how I can do that. Any idea?

Thanks

Last edited by Myusername (2020-08-30 05:00:28)

Offline

#2 2020-08-30 05:13:18

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

Re: Loop with articles from two sites ordered by date

Sorry I cannot think of a way but is there a strong reason you did the second install or could both contents co-exist in one db?


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

Offline

#3 2020-08-30 05:44:59

Myusername
Member
Registered: 2019-12-12
Posts: 162

Re: Loop with articles from two sites ordered by date

colak wrote #325662:

Sorry I cannot think of a way but is there a strong reason you did the second install or could both contents co-exist in one db?

The reason for the second installation is basically a lot of content on the website. I need more organization mainly on the back end. Every day my website produces a lot of content on many subjects, and having them all mixed up is a mess.

So, I believe that this new installation is interesting, I manage to keep some content separate, including categories and sections of that content. However, on the front-end, I would like to keep a feed with our latest updates, from whatever part of the site.

Is it a bad idea?

Anyway, I got a satisfactory result this way:

<txp:variable name='looplimit' value='10'/>
<txp:variable name="loopoffset" value='<txp:evaluate query=''<txp:page_url type="pg" /> * <txp:variable name="looplimit"/> - <txp:variable name="looplimit"/>'' />' />
.
<txp:etc_query globals='variable, thispage' data="SELECT * FROM textpattern WHERE Status = '4' UNION ALL SELECT * FROM elctextpattern WHERE Status = '4' ORDER BY Posted desc LIMIT {?looplimit} OFFSET {?loopoffset}">
   <h1>{Title?}</h1>
   <p>{Posted?}</p>
<txp:else />
   <p>Nobody here.</p>
</txp:etc_query>

As I will not use <txp: article> on the homepage, I think it works.

Last edited by Myusername (2020-08-30 05:47:05)

Offline

Board footer

Powered by FluxBB