Page 1 of 1
adding a text in udt[SOLVED]
Posted: Fri Dec 23, 2011 10:25 pm
by olumide
Hello please i need to place a code text in a variable that gets written to mysql database but not sure how to do this without getting an error
here is the code
Code: Select all
$templatetext =" {strip}
{if isset($banner.clickthrough)}
<a rel="nofollow" href="{$banner.clickthrough}" title="{$banner.name}"><img src="uploads/{$banner.image}" width="220" height="220" alt="{$banner.text|default:''}"/>
</a>
{else}
{* no url found, just displaying an image *}
<img src="uploads/{$banner.image}" width="450" height="68" alt="{$banner.text|default:''}"/>
{/if}
{/strip}
"
Re: adding a text in udt
Posted: Fri Dec 23, 2011 11:41 pm
by spcherub
You have not posted sufficient information in order for us to help you. Can you show what you've done so far?
Re: adding a text in udt
Posted: Sat Dec 24, 2011 12:15 am
by olumide
thanks here what i have done so far
Code: Select all
$banner_category_id= $db->GenID( cms_db_prefix () . "module_banners_categories_seq");
$banner_name = "Supplier_" . $q;
$banner_desc = $category_desc;
$uploads_category_id = $category_id;
$banner_template = "
{strip}
{if isset($banner.clickthrough)}
<a rel="nofollow" href="{$banner.clickthrough}" title="{$banner.name}"><img src="uploads/{$banner.image}" width="220" height="220" alt="{$banner.text|default:''}"/>
</a>
{else}
{* no url found, just displaying an image *}
<img src="uploads/{$banner.image}" width="450" height="68" alt="{$banner.text|default:''}"/>
{/if}
{/strip}
";
$query = "INSERT INTO " . cms_db_prefix() . "module_banners_categories
(category_id, name, description, uploads_category_id, template, dflt_image, dflt_url)
VALUES (?,?,?,?,?,?,?)";
$dbresult = $db->Execute( $query, array (
$banner_category_id,
$banner_name,
$banner_desc,
$uploads_category_id,
$banner_template,
$mmm,
$mmmm));
if (!$dbresult) {return;}
Re: adding a text in udt
Posted: Sat Dec 24, 2011 2:52 am
by spcherub
It looks like you've only posted a snippet of your code, or if that is not the case you are missing a bunch of declarations in the beginning of the UDT. Also it would be helpful if you posted the error messages you received.
One potential source for the error is where you assign the $banner_template variable. You should make this assignment with single quotes and not double-quotes. This will prevent the interpreter from thinking that references like {$banner.image} are meant to be substituted immediately. So change your variable assignment to something like this:
Code: Select all
$banner_template = '
{strip}
{if isset($banner.clickthrough)}
<a rel="nofollow" href="{$banner.clickthrough}"
...
...
';
There may be other problems, but as I said earlier it is hard to know until you post your entire UDT and/or the error messages.
Hope this helps.
-S