21492 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 575 Views |
-
replacing content newbie need help

28 July 2010 at 3:22am
Hi
I have a problem trying to do this :
Replace the value of a variable called $contentdisplay based on the value of a variable called $contenttype and this should be triggered by a link in the template.
So I tried to do it this way.
I created several tabs in cms admin using this to define the :
static $db = array(
'ActifsProduct' => 'HTMLText',
'TextProduct' => 'HTMLText',
'GestesProduct' => 'HTMLText',
'SecretProduct' => 'HTMLText',
'ImageName' => 'Text',);
public function getCMSFields()
{
$f = parent::getCMSFields();$f->addFieldToTab('Root.Content.ActifsProduct', new HtmlEditorField('ActifsProduct'));
$f->addFieldToTab('Root.Content.TextProduct', new HtmlEditorField('TextProduct'));
$f->addFieldToTab('Root.Content.GestesProduct', new HtmlEditorField('GestesProduct'));
$f->addFieldToTab('Root.Content.SecretProduct', new HtmlEditorField('SecretProduct'));
$f->addFieldToTab('Root.Content.Main', new TextField('ImageName'), 'Content');
return $f;}
}Then in my controler I did this
class ProductPage_Controller extends Page_Controller
{public SwitchContent(){
if ($contenttype == 'content01')
{$contentdisplay = $this ->TextProduct};
elseif ($contenttype == 'content02')
{ $contentdisplay = $this ->GestesProduct};
elseif ($contenttype == 'content03')
{ $contentdisplay = $this ->SecretProduct};else {$contentdisplay = $this ->ImageName};
return $contentdisplay
}}
finally in my template I got this
<% control SwitchContent %>
<div id="NavDescriptif">
<li><a href="$Link?$contenttype='content01' " class="$LinkingMode">content01</a></li>
<li><a href="$Link?$contenttype='content02' " class="$LinkingMode">content02</a></li>
<li><a href="$Link?$contenttype='content03 " class="$LinkingMode">content01</a></li>
$contentdisplay
<% end_control %>
[c/ode]I really need a hand on this because my project is stuck...
I get a syntax error on the php code part
Thanks a lot for your help
-
Re: replacing content newbie need help

28 July 2010 at 9:07pm
public SwitchContent(){
if ($contenttype ...
You have not defined $contenttype anywhere before in that function so of course PHP will throw an error.
-
Re: replacing content newbie need help

28 July 2010 at 9:12pm
oups I made a mistake copying my code it is suposed to be :
public function SwitchContent() {...}
But in fact I feel I'm not doing this the right way.
I had another answer on some other point telling me that to do what i wanted ( displaying tabbed content) I should use Jquery.
What do you suggest can I do it without Jquery or not ?
Thank you
-
Re: replacing content newbie need help

28 July 2010 at 9:30pm
You can always write jQuery to display the tabs for you but jQuery tools [1] and jQuery UI do provide tabbing functionality out of the box
[1] http://flowplayer.org/tools/tabs/index.html
[2] http://jqueryui.com/demos/tabs/ -
Re: replacing content newbie need help

28 July 2010 at 9:35pm
Thanks a lot Willr
I will take a look at this but it seems quite easy to use.
I will try this today and let you know how it goes but I think you saved me ;)
One more question do I have to install Jquery in SS or is it provided with it I'm currently using 2.4 stable
Thanks Again
-
Re: replacing content newbie need help

28 July 2010 at 11:11pm
SS 2.4 includes jQuery 1.4.2 in the download. To include it on your webpage you can do the following in your Page.ss
<% require javascript(sapphire/thirdparty/jquery/jquery.js %>
-
Re: replacing content newbie need help

29 July 2010 at 3:15am
Hello
Thanks a lot !!!!
I'm ok now
those tools are amazing .
That was vey nice of you to poit them !
Thanks
| 575 Views | ||
|
Page:
1
|
Go to Top |


