340 Posts in 140 Topics by 176 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1331 Views |
-
Writing a IF Loop

10 December 2009 at 1:56am
Hello
I Want to write a page link in two line for a particular link,I am giving the code in pure php.i need to implement the same code in silverstripeif($MenuTitle=="Commentating ,& After Dinner Speeches" )
{$a=explode(',',$MenuTitle);
$MenuTitle=$a[0]."<br/>".$a[1];}
NOTE:What I am doing is,I am trying to break the link of the page name 'Commentating ,& After Dinner Speeches' into two part, and display the link in navigation as
Commentating
& After Dinner SpeechesThank you in advance
Please help me out in solving this issue -
Re: Writing a IF Loop

10 December 2009 at 8:52am
In your page class, create a method like:
function MultiLineTitle($delimiter = ",") {
$title = explode($delimiter, $this->MenuTitle);
foreach($title as $key => $value)
$title[$key] = Convert::raw2xml($value);
return implode("<br />", $title);
}Then in your template:
$MultiLineTitle
If you want to use something other than "," to mark the division between text:
$MultiLineTitle(#)
etc...
-
Re: Writing a IF Loop

11 December 2009 at 7:32pm
Thank you Hamish for your reply and trying to solve my issue,I am new in silverstripe,its only few days since i am using silverstrip,Can you kindly let me know where I will get the page class,it will be very kind of you if you can let me know the page name and its location where i need to add the function.
In the template i know where to add the calling -
Re: Writing a IF Loop

12 December 2009 at 12:57am
Hello Hamish
As per your instruction I have created the method in page.php and I replaced $MenuTitle with $MultiLineTitle but when I did that none of the menu title appears in the page.I have added a dropdown menu in my website.May be thtat is causing the problem so i am providing you the code of navigation.ss pageNavigation.ss
<!-- [if IE6]><div id="IE6"><![endif]-->
<ul id="menu1">
<% control Menu(1) %>
<% if Children %>
<li class="$LinkingMode"><a href="$Link" class="sub" title="View more info about $Title"><span>$MenuTitle</span><!--[if gte IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul class="fly $LinkingMode">
<% control Children %>
<% if Children %>
<li class="$LinkingMode"><a href="$Link" class="fly" title="View more info about $Title"><span>$MenuTitle</span><!--[if gte IE 7]><!--></a><!--<![endif]-->
<!--[if lte IE 6]><table><tr><td><![endif]-->
<ul>
<% control Children %>
<li><a href="$Link" title="View more about $Title" class="$LinkingMode">$MenuTitle</a></li>
<% end_control %>
</ul><!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
<% else %><li><a href="$Link" title="View more about $Title" class="$LinkingMode">$MenuTitle</a></li>
<% end_if %>
<% end_control %>
</ul>
<!--[if lte IE 6]></td></tr></table></a><![endif]-->
</li>
<% else %>
<li class="$LinkingMode"><a href="$Link" class="top_link" title="View more info about $Title"><span>$MenuTitle</span></a></li>
<% end_if %>
<% end_control %>
</ul>
<!-- [if IE6]></div><![endif]-->Thank you for taking so much time and helping me.
| 1331 Views | ||
|
Page:
1
|
Go to Top |


