17488 Posts in 4473 Topics by 1978 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 2397 Views |
-
$Link taking on the properties of nearest < %control %>

7 May 2008 at 6:29am
Hi,
When I place the $Link variable in under the <% control ResizedImage(340,340) %> control, then $Link points to /assets/Uploads/ResizedImageblah.jpg. This make sense, however, I want the link to point to the subpages I created (<% control Children %>).
How do I do this?
<% control Children %>
<div class="left_sect">
<% control SectPic %>
<% control ResizedImage(340,340) %>
<a href="$Link">$Title</a>
<img class="art_sect" src="$URL" alt="$Title" width="224" height="168" />
<% end_control %>
<% end_control %>
</div>
<% end_control %> -
Re: $Link taking on the properties of nearest < %control %>

7 May 2008 at 7:44am
Why not put the link out of the image-control?
Like this?
<% control Children %>
<div class="left_sect">
<a href="$Link">$Title</a>
<% control SectPic %>
<% control ResizedImage(340,340) %>
<img class="art_sect" src="$URL" alt="$Title" width="224" height="168" />
<% end_control %>
<% end_control %>
</div>
<% end_control %>You can also access outer controls with using $Top...
see http://doc.silverstripe.com/doku.php?id=built-in-page-controls#dataobjectset_options -
Re: $Link taking on the properties of nearest < %control %>

7 May 2008 at 10:09am
Hey Dio!
What I really want to do is to link the resized images to their corresponding subpages like so:
<a href="$Link"><img class="art_sect" src="$URL" alt="$Title" width="224" height="168" /></a>
I just wanted to separate the two to make so as not to cause confusion.
-
Re: $Link taking on the properties of nearest < %control %>

7 May 2008 at 10:22am Last edited: 7 May 2008 10:23am
Same thing,
just put the control for the images in the link...
<a href="$Link">
<% control SectPic %>
<% control ResizedImage(340,340) %>
<img class="art_sect" src="$URL" alt="$Title" width="224" height="168" />
<% end_control %>
<% end_control %>
</a>Or even:
<a href="$Link"><img class="art_sect" src="<% control SectPic %><% control ResizedImage(340,340) %>$URL<% end_control %><% end_control %>" /></a>
or something like that...
-
Re: $Link taking on the properties of nearest < %control %>

7 May 2008 at 10:44am
Thanks!
Both worked great.
Todd
-
Re: $Link taking on the properties of nearest < %control %>

13 October 2008 at 9:57pm
Of course if one wants to do something like this:
<ul>
<% control LatestIssues %>
<li><a href="$Link/view/$ID">$Title</a></li>
<% end_control %>One runs into the problem again. So how does one refer to parameters within the structures surrounding the current control.
Would be useful to do something like: $Page.Link, or if in a nested control structure, something like ControlStructure.Title e.g. $LatestIssues.Title. This would allow for nesting of control structures with full access to surrounding parameters.
Kevin
P.s. Since $Page.Link doesn't work I will be embedding the Link into the control structure within the controller.
-
Re: $Link taking on the properties of nearest < %control %>

13 October 2008 at 10:37pm
Well that worked.... now where in the docs did you find that?
Cheers
Kevin
| 2397 Views | ||
|
Page:
1
|
Go to Top |


