Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Article Custom questions
Hi – I’ve got 3 boxes, each which contain a list of custom articles and I order the boxes by the order of the categories:
<txp:article_custom form="sr-box" limit="4" category="celebrity-style,beauty-reporter,travel-hotspot,style-presenter" />
Without giving access to the code, is there a way in which I can give a client a way to order the boxes from within the admin?
Offline
#2 2009-06-06 23:16:51
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article Custom questions
Do you still need this? I think there is a way to do it using either a form or an article, depending on what you want to give your client access to.
Offline
Re: Article Custom questions
Hey Els – yes I do please :)
Offline
Re: Article Custom questions
tye wrote:
Hey Els – yes I do please :)
For example you could create an article that contains the settings. For example in the custom fields – or as a array in the article body.
Second method (descriped below) is to add rows to txp_prefs
table in the TXP db. Those rows are then automatically listed on the backend preferences page (as text fields).
For example you could run query similiar to:
INSERT INTO txp_prefs (
prefs_id=1,
name='my_custom_sort',
val='id desc',
type=1,
event='sort',
html='text_input',
position=20
)
That query will add a new group called sort
to the Advanced preferences and a new text field under it, called my_custom_sort
. Now there is field, yahoo!
By doing so, managing the order/sort is fairly easy: it’s just matter of writing couple words into text fields. Not much work for the end-user :-)
Now, we do still need to pull the data out from the db on the frontend. Easiest is probably to do little fetching and place the data into <txp:variable />
. For example the query could look like:
<txp:php>
fetch('val', 'txp_prefs','name', 'my_custom_sort');
</txp:php>
…where the new row you created is my_custom_sort
.
Now, to simplify the code and to make it more easy to modify and locate, we might want to place it into the variable tag. At same time we could re-use it later with out causing double queries. Example:
<txp:variable name="my_custom_sort" value='<txp:php> fetch('val', 'txp_prefs','name', 'my_custom_sort'); </txp:php>' />
Now we have variable called my_custom_sort
which contains the data of my_custom_sort
prefs field. Now let’s insert it into the article
-tag:
<txp:article_custom sort='<txp:variable name="my_custom_sort" />' />
And that’s it. Fairly simple.
If you want you can go even nuts with the method. For example:
<txp:article_custom category='<txp:variable name="my_custom_sort1" />' />
<txp:article_custom category='<txp:variable name="my_custom_sort2" />' />
<txp:article_custom category='<txp:variable name="my_custom_sort3" />' />
…where every category would be inside it’s own field, which is one way to sort them. You can pretty much do anything with the prefs fields.
Last edited by Gocom (2009-06-09 03:44:12)
Offline
#5 2009-06-09 16:52:53
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article Custom questions
I think my method is much simpler, but just to make sure: all you want is that the client can determine the order of celebrity-style,beauty-reporter,travel-hotspot,style-presenter
, right?
Offline
Re: Article Custom questions
Els – Yes – all I need is the ability to change the order.
Gocom – Thanks for that, I’ll look into yours in more detail as txp:variable is something I haven’t used yet… looks interesting though
Offline
#7 2009-06-10 06:35:58
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article Custom questions
Hmm… I’m beginning to wonder how you are achieving the sort by category. Because the order of the values in category="..."
doesn’t sort your articles… It would be easy to make that adaptable, but now I don’t think that is what you need. Is the sorting done in your form ‘sr-box’?
Offline
Re: Article Custom questions
Sorry for the late reply Els – I’ve been away :)
The design has changed a little now, and there is just one article in each box with a link through to the pages… so article sorting is not needed :)
Offline
#9 2009-06-24 17:09:34
- els
- Moderator
- From: The Netherlands
- Registered: 2004-06-06
- Posts: 7,458
Re: Article Custom questions
tye wrote:
so article sorting is not needed :)
Oh good. I forgot my solution anyway, so that would have been a bit embarrassing… ;)
Offline
Pages: 1