Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-12-28 04:45:42

elihu252
Member
Registered: 2006-10-27
Posts: 23

Use a Custom Field to modify lines of code in a form?

Is it possible to use custom fields to modify lines of code in a form.

For example:

I would enter “verycool” into a custom field, and it would insert it into a line of code in a form such as, <img src=“veycool.jpg”>

And my form would look something like <img src=”<txp: custom>.jpg”>

any help would be greatly appreciated.

Offline

#2 2007-12-28 06:35:06

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Use a Custom Field to modify lines of code in a form?

elihu252

Yes, it’s possible to use custom fields to do this but why bother making the .jpg common? It will stop you from using this method for png or gif files too.

Something like …

<txp:if_custom_field name="image">
<img src="<txp:custom_field name="image">" />
</txp:if_custom_field name="image">

Should do it. Make sure you call one of your custom fields “image” from the advanced prefs.

Now just type “verycool.jpg” or “anothercoolone.gif” (drop the quotes of course) into the image field on your article and all should work.


Steve

Offline

#3 2007-12-28 06:53:49

elihu252
Member
Registered: 2006-10-27
Posts: 23

Re: Use a Custom Field to modify lines of code in a form?

are you sure you can enter <txp> tags inside of html code like that? it always breaks my site when i do it.

Offline

#4 2007-12-28 07:07:47

sthmtc
Member
From: CGN, GER
Registered: 2005-01-17
Posts: 586
Website

Re: Use a Custom Field to modify lines of code in a form?

elihu252 wrote:

are you sure you can enter <txp> tags inside of html code like that? it always breaks my site when i do it.

absolutely — that’s what it’s all about! :)
maybe you forgot to close the txp tag, like <txp:article_image> instead of the correct <txp:article_image /> ?

Offline

#5 2007-12-28 13:09:42

net-carver
Archived Plugin Author
Registered: 2006-03-08
Posts: 1,648

Re: Use a Custom Field to modify lines of code in a form?

elihu252 wrote:

are you sure you can enter <txp> tags inside of html code like that?

Sure, like sthmtc says, that’s what it’s about, gives Txp a lot of power.

it always breaks my site when i do it.

You’re probably making a simple mistake somewhere. For example, not all Txp tags can be used in all places. Some, like the custom field tags in the example I posted should only be used in article forms — or places where the context is restricted to a single article.


Steve

Offline

#6 2007-12-28 17:10:42

benbruce
Plugin Author
Registered: 2006-01-13
Posts: 328
Website

Re: Use a Custom Field to modify lines of code in a form?

This may not be important but … you can’t use TXP tags inside TXP tags the way you ca. n use them in HTML. There is a hack, which (although it says it doesn’t always work) has worked for me in every case.

  • Ben

Offline

Board footer

Powered by FluxBB