Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
#1 2006-04-27 12:20:58
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Random archived page.
Hello,
I’m trying to add a link on my photoblog that will link to a random older entry in my archives. So far, I’m not finding too many scripts to do this. But especially one issue is, I expect such a script would have to sit in the same directory where my blog is, or at least be able to point to it, namely: http://urbangriffin.com/photolog/. But, I realise I cannot find such a directory on my FTP server, as my TXP install sits in the root of my domain. The problem being also that most scripts like this will look for ‘.html’ files within the relevant directory. And as my URLs indicate, each archive article is a directory onto itself, containing just one index.html file representing it: ‘http://domain.com/blogsectiondirectory/articlenamedirectory/index.html’.
The only solution then would be a script where I would have to specify by hand a list of all my archive entries, but I’d rather a script that could do this live and could keep up as I update my blog.
Any idea how would I go about achieving a randomizer on my TXP blog in the most effcient manner ?
Last edited by lisionosk (2006-04-27 12:52:57)
Offline
#2 2006-04-27 14:21:14
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Random archived page.
lisionosk wrote:
I expect such a script would have to sit in the same directory where my blog is, or at least be able to point to it, namely: http://urbangriffin.com/photolog/. But, I realise I cannot find such a directory on my FTP server, as my TXP install sits in the root of my domain.
I have this on my page: <txp:php>include "script.php";</txp:php>
, the php file is in the root, and it works in every section.
Do I understand correctly that your archives are not in Textpattern?
Offline
#3 2006-04-27 14:28:17
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Re: Random archived page.
Well, if I go on my FTP server and look in my root directory or inside the Textpattern folder, I cannot see any of my section directories, like ‘/photolog/’, or any of the content managed by TXP, really. Funny, I only just noticed that. It seems the only way I could edit any of my pages would be through the TXP interface, and not from the FTP server. Strange…
Offline
#4 2006-04-27 14:31:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Random archived page.
Textpattern doesn’t create directories or pages, it’s all in the database.
But are your archives in Textpattern or not, because if they are it’s very easy to show a random entry.
Offline
#5 2006-04-27 14:34:43
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Re: Random archived page.
Well, I would suppose my archives are within TXP… Anyway, I’m listening on with interest now. :)
Offline
#6 2006-04-27 14:40:49
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Random archived page.
<code><txp:article_custom section=”…” category=”…” form=“yourform” limit=“1” sortby=“rand()” />
</code>
In ‘yourform’ for example:
<code>
See a random entry from my archives: <txp:permlink><txp:title /></txp:permlink>
</code>
(I thought maybe your archives were in some other CMS, in which case you of course would need a script of some sorts.)
Offline
#7 2006-04-27 15:01:30
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Re: Random archived page.
Thank you, Els. Can <code><txp:article_custom section=“photolog” form=“random_form” limit=“1” sortby=“rand()” /></code> be placed inside a form instead of a page ? So far, it’ll only function when placed in a page template.
Offline
#8 2006-04-27 15:08:53
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Random archived page.
You mean in an article form? Yes, I just tried that. (With <txp:article />
you can’t do this though.)
Offline
#9 2006-04-27 15:12:04
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Re: Random archived page.
With a <code><txp:article /></code> already in the main page template, you mean ? Yes, it messes it up, then. Thank you for your patience, I’ll figure something.
Offline
#10 2006-04-27 15:49:24
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Random archived page.
No, that should be possible. On the page <txp:article form="x" />
and in form ‘x’ <txp:article_custom />
. I tried it, it works. What I meant was that you can’t put a <txp:article />
tag in an article form.
Last edited by els (2006-04-27 15:49:55)
Offline
#11 2006-04-27 16:04:57
- lisionosk
- Member
- From: Switzerland
- Registered: 2006-02-10
- Posts: 99
Re: Random archived page.
Mmm, I thought hard but I’m having trouble following your idea.
Here is the code in my ‘page’:
<code><txp:else />
<txp:article form=“photolog_form” limit=“1” /></txp:if_section></code>
And here is the piece of code in my ‘form’ where I would like to include the ‘random’ link as an additional <code><li></code>:
<code><txp:if_comments_allowed><li><txp:comments_invite showalways=1 /><br></li></txp:if_comments_allowed><li><a href=”/archives/”>view all</a></li></ul></code>
So, I have created a ‘random_form’ form that includes only the following line:
<code><txp:permlink>random</txp:permlink></code>
Then, where should I place <code><txp:article_custom section=“photolog” form=“random_form” limit=“1” sortby=“rand()” /></code> in order for it to work, now ?
Offline
#12 2006-04-27 18:59:30
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Random archived page.
What do you have before the first “else” tag, what is the section you’re checking for?
Offline