adding a text in udt[SOLVED]

General project discussion. NOT for help questions.
Post Reply
olumide
Forum Members
Forum Members
Posts: 108
Joined: Mon Mar 21, 2011 10:26 am

adding a text in udt[SOLVED]

Post 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}
"
Last edited by olumide on Sat Dec 24, 2011 11:03 am, edited 1 time in total.
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: adding a text in udt

Post by spcherub »

You have not posted sufficient information in order for us to help you. Can you show what you've done so far?
olumide
Forum Members
Forum Members
Posts: 108
Joined: Mon Mar 21, 2011 10:26 am

Re: adding a text in udt

Post 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;}
spcherub
Power Poster
Power Poster
Posts: 402
Joined: Fri Jun 06, 2008 5:54 pm

Re: adding a text in udt

Post 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
Post Reply

Return to “General Discussion”