21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 531 Views |
-
This is going to seem very n00b, but...

4 August 2010 at 11:16pm
Ok, so i'm building a web app using sapphire as the framework and doing it the proper MVC way and basically bypassing the CMS (using my controller to define the pages dynamically a la codeigniter, rails etc.) because it's mainly a UGC site. I have one question though and one thing that despite becoming VERY familiar with the SS documentation I still can't work out the best way to do a simple hyperlink intelligently. like sure i can do href="/mysite/controller/action/ID" but that's not dynamic enough. is there something i've missed that can allow me to create links like rails' link_to? or a page that summarises the various link modes (but isn't cms centric given i'm not really using it at all).
-
Re: This is going to seem very n00b, but...

5 August 2010 at 8:07pm
I still can't work out the best way to do a simple hyperlink intelligently
Well the best way is to first define a Link method on your dataobject. Since then you can use $Link in the template and things like rss, restful will all be able to $Link as per.
but that's not dynamic enough
How dynamic did you need it do be? Normally on your dataobject you have a specific controller tied to displaying it. By default you can follow the convention of using a argument to determine the action. For example often you will see this on dataobjects.
function Link($action = "show") {
return "controller/$action/". $this->ID. ";
}So then using $Link(edit) and $Link(delete) works nicely. If you need controller to be an actual page object (with a 'nice' url) you could also do a lookup for that rather than hardcoding controller.
-
Re: This is going to seem very n00b, but...

10 August 2010 at 7:08pm Last edited: 10 August 2010 7:08pm
Ah of course, thanks so much for that! makes perfrect sense.
One more question that I had neglected to consider before:
I've currently got my app setup in the usual way with the theme having a default page.ss template file which is extended by layout and includes. the problem now of course is that all my controllers don't extend Page. What is the best way to structure a template in this instance? WIll layout still apply? Will page still be the default base template which everything else extends from like when I call renderWith->(some form of template in layout) work by parsing page, then any includes, then the requested layout template, or is that only for the CMS? I've been trying to find where the layout method is defined, but i'm probably too tired to work it out properly!
| 531 Views | ||
|
Page:
1
|
Go to Top |


