Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2006-01-31 18:19:40

goncalo.dumas
Member
From: Lisbon
Registered: 2005-12-14
Posts: 97
Website

Custom field + PHP = Happiness

Following this previous thread, I’ve managed to start using 6 custom fields (of the available 10) to specify the image id of each of the 6 thumbnails that will appear on the article being edited.

But since custom fields are so precious to me (and I think to all of you…), I started wondering if it would be possible to compact this information into one single custom field – that is, using some sort of “information transport” widget.

This way, someone could enter – as an example:
custom_field_2=”2,6,13,22”
Instead of:
custom_field_2=”2”
custom_field_3=”6”
custom_field_4=”13”
custom_field_5=”22”

Then, in a form, some sort of “PHP evil code” :o) would break this message delivered by the custom_field_2 and assign each part to the expectant recipient, like this:
txp:thumbnail id=”2”
txp:thumbnail id=”6”
txp:thumbnail id=”13”
txp:thumbnail id=”22”

Do any of you guys/girls have an hint? Thanks.

Last edited by patchwork (2006-01-31 18:27:48)

Offline

#2 2006-01-31 18:47:47

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Custom field + PHP = Happiness

Will all let you do that using the article image field. A combination of the offset and limit attributes that upm_article_image or hak_article_image offer should allow you pretty good control over what goes where.

You could probably take any of those and adapt it to use a custom field if the article image field won’t work for some reason.

Last edited by hakjoon (2006-01-31 18:48:18)


Shoving is the answer – pusher robot

Offline

#3 2006-01-31 23:33:11

goncalo.dumas
Member
From: Lisbon
Registered: 2005-12-14
Posts: 97
Website

Re: Custom field + PHP = Happiness

Thanks Patrick!!

Thanks for pointing me the way.
I will install your plugin – It seems to be just what I was looking for.

As for the gallery, it’s all sorted out and working.

Last edited by patchwork (2006-01-31 23:46:14)

Offline

#4 2006-02-01 00:36:21

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Custom field + PHP = Happiness

Hope it let’s you do what you want. If not post suggestions over on the hak_article_image thread or the upm_img_popper thread

Since I’m maintaining upm_img_popper now I’m planning on integrating the two so suggestions are always welcome.

Oh and make sure you get the 0.3.3 version of hak_article_image I just posted today. It fixes a bug with using offset and limit together. Which reminds me I should check if upm_img_popper doesn’t have the same issue.


Shoving is the answer – pusher robot

Offline

#5 2006-02-01 00:42:54

Hans
Member
From: Everywhere
Registered: 2004-03-07
Posts: 99
Website

Re: Custom field + PHP = Happiness

Or, if you really just want to use PHP, you could <code>explode</code> the custom field (<code>@$prefs[‘custom_1_set’]</code>) and then using the split-up variables as so: <code>txp:thumbnail id=”<txp:php print $1 </txp:php>”
txp:thumbnail id=”<txp:php print $2 </txp:php>”</code> etc.


Lumilux – A Photoblog

Offline

#6 2006-02-01 09:34:20

goncalo.dumas
Member
From: Lisbon
Registered: 2005-12-14
Posts: 97
Website

Re: Custom field + PHP = Happiness

Patrick, I did go to your site looking for the updated version, thanks once again.

Hans, thanks for your answer, it will be pretty useful!

I usually try to restrict the use of plugins but the hak_article_image seems to be pretty light and easy to use.
Nevertheless the explode procedure will be very useful in other uses of the custom fields.

Offline

#7 2006-02-01 13:24:50

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Custom field + PHP = Happiness

One thing about hak_article_image (and I’m sure other plugins out there as well) in regards to the whole, plugin or no plugin debate.

It’s really just a wrapper for the built in image and thumbnail functions, so most of the core functionality that is prone to break with updates is actually handled by TXP itself.

I spent a good chunk of time retrofitting zem’s original plugin (which I think came out for RC1) to use many of the native functions that got added since it originally came out, in an effort to make it reasonably future proof.


Shoving is the answer – pusher robot

Offline

Board footer

Powered by FluxBB