Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

$SiteConfig.Tagline not working within a loop


Go to End


4 Posts   1359 Views

Avatar
RichMcNabb

Community Member, 34 Posts

15 November 2010 at 11:03am

Hi,

I have added a company tagline which I can access from ss templates using $SiteConfig.Tagline. However I am having trouble when trying to access the tagline within a loop:

<% control Branches %>
<div class="office_location"><a name="$Name" id="$Name"></a>
<div class="office_details">
<h2>$Name CDP Office</h2>
<p>$Location $SiteConfig.Tagline</p>
<div class="office_map"> <a href="$GoogleMap" target="_blank"><img src="$LocationMapImage.LocationMap.URL" alt="View the $Name CDP office on Google maps" title="View the $Name CDP office on Google maps" width="$LocationMapImage.LocationMap.Width" height="$LocationMapImage.LocationMap.Height" /></a>
<p class="view_google_map"><a href="$GoogleMap" target="_blank" title="View the $Name CDP office on Google maps">View Google map directions &raquo;</a></p>
</div>
</div>
<div class="clear"> </div>
<% end_control %>

I suspect the problem may be when I am accessing the branches it is unable to locate information outside of that. Is there any way I could make it globally acessiable.

Any help would be greatly appreciated. Cheers!

- Rich McNabb

Avatar
swaiba

Forum Moderator, 1899 Posts

15 November 2010 at 11:35am

yep, when in a loop you move to that "context". to access the top level context try...

<p>$Location $Top.SiteConfig.Tagline</p> 

Avatar
RichMcNabb

Community Member, 34 Posts

15 November 2010 at 12:10pm

Thanks swaiba that works great!!

I have one more question about accessing another page. I have 3 training pages:

TrainingIntro.php (introduction with a training schedule download)
> TrainingHolder.php (course subjects listed)
>TrainingPage.php (course overview)

On TrainingIntro.php I can access the the pdf download by using $TrainingScheduleDownload.URL. However on TrainingPage.php I can't and am not sure how I would go about accessing something that is 2 levels above.

Would I need a function that gets the info from TrainingIntro or can I specify a page directly using something like (training-intro)$TrainingScheduleDownload.URL

Any help would be fantastic. Thanks again.

Avatar
RichMcNabb

Community Member, 34 Posts

15 November 2010 at 1:31pm

Found it!!

$Page(Training).TrainingScheduleDownload.URL