Page 1 of 1

Help with type in theme configurator

Posted: Fri Oct 27, 2006 8:12 pm
by carl_galloway
I'm trying to create a textbox within the theme configurator that will allow me to place some html directly into the entry page.

My code in config.inc.php looks like this;

Code: Select all

    array(
        'var'           => 'html_snippet',
        'title'         => 'HTML',
        'description'   => 'Add you code here',
        'type'          => 'text',
        'default'       => ' ',
    ),
The code is saved to hte database no problem, but when I try to access the code in entries.tpl I get a fatal error Fatal error: Cannot use string offset as an array

In entries.tpl I have

Code: Select all

{if $template_option.html_snippet_toggle == 'true'}<div class="userhtml">{$template.option.html_snippet}</div>{elseif $template_option.html_snippet_toggle == 'false'}{/if}
Why isn't this working, and can we have a complete list of types available please?

Re: Help with type in theme configurator

Posted: Sat Oct 28, 2006 12:59 am
by yellowled
carl_galloway wrote:Why isn't this working, and can we have a complete list of types available please?
Just a guess: http://www.s9y.org/137.html says:
The "type" array index specifies, how your option shall be shown to the user. Values can be: select, tristate, boolean, radio, string, html, hidden.
So you should maybe use 'string' as the type instead of 'text'? Although I admit I don't have the slightest idea how big this string can be ...

Posted: Sat Oct 28, 2006 1:38 am
by carl_galloway
Yeah, but 'text' works, it actually produces a large size textarea for typing a block of text, whereas string only generates an input box. In fact textarea itself tries to open the html editor and fails, so the page you mention is either out of date or hidden options exist that Garvin hasn't finalised yet.

I actually do want to put a textarea into the configurator, and users might want to use the box for advertising such as Google, and I don't want to use the html nugget, so I really feel that we need to get a handle on all the options that are available. Garvin, could you help?

Posted: Mon Oct 30, 2006 9:58 am
by garvinhicking
Hi!

Yeah, the text type should work.

Carl, can you give me the full PHP error message? The message actually says that you try to access the $template_option array, but in your case this is not an array but a string. This can happen if the DB query failed somehow.

To debug it further, I'd need more info; maybe the whole template if you can send me to reproduce it.

Regards,
Garvin

Posted: Mon Oct 30, 2006 6:31 pm
by carl_galloway
Hi Garvin, I'll email the template files to you. Maybe I've just got a typo.

Posted: Wed Nov 08, 2006 1:55 pm
by yellowled
Have you guys solved this issue in the meantime?

YL

Posted: Wed Nov 08, 2006 5:21 pm
by carl_galloway
sorry, yeah we did, turns out I had let a typo into my code.

In the entries.tpl code I had inadvertently used a period instead of an underscore. The correct code is

Code: Select all

{if $template_option.html_snippet_toggle == 'true'}<div class="userhtml">{$template_option.html_snippet}</div>{elseif $template_option.html_snippet_toggle == 'false'}{/if}

Posted: Wed Nov 08, 2006 10:44 pm
by yellowled
carl_galloway wrote:sorry, yeah we did, turns out I had let a typo into my code.
In your example you wanted to insert HTML code into the entry page - is there any reason why this shouldn't work or be used to insert Javascript into the index page? I'd like to use this to insert counter code (in Javascript).

YL

Posted: Thu Nov 09, 2006 2:38 am
by carl_galloway
Actually I tested it using html and also adsense code and they both worked, it also happily accepts technorati code,so I don't see why counter code wouldn't also work. On the other hand if you wanted to insert javascript with curly backets I haven't tested that.

Posted: Thu Nov 09, 2006 1:45 pm
by yellowled
I've tested it, but the code isn't inserted, so I was wondering whether I need additional code in the config.inc.php because of the variable $template_option.html_snippet_toggle ..? I don't get any errors, but the code is not inserted.

YL

Posted: Fri Nov 10, 2006 1:48 am
by carl_galloway
Mist! sorry dude, I didn't include the other bit of the config code, add this to your config.inc.php;

Code: Select all

    array(
        'var'           => 'html_snippet_toggle',
        'title'         => 'Toggle ad code',
        'description'   => 'Display ad for entries and static pages?',
        'type'          => 'radio',
	  'radio'         => array('value' => array('true', 'false'),
					'desc' => array('Yes', 'No')),
        'default'       => 'false',
    ),

Posted: Fri Nov 10, 2006 12:15 pm
by yellowled
carl_galloway wrote:Mist!
:D
carl_galloway wrote:sorry dude
This would by the way be 'Entschuldigung, Alter' in German although many young people would probably already use 'Sorry, Alter'. (And for all our confused readers: Carl and his better half are learning German.)
carl_galloway wrote:I didn't include the other bit of the config code, add this to your config.inc.php
Yeah, I figured something was missing :) This works, thanks once again.

YL