What is the preferred method of generating links?
Permalink
I've seen a couple different methods for generating links in concrete5 and I'm not sure what the pros and cons are of each. In the view I've seen:
and
And in controllers, tools, etc. I've seen the navigation helper method above and also:
There might even be other methods that I'm leaving out.
So I'm wondering which method is best to use? I have to think using View::url() is more efficient since you don't have to load in the navigation helper and make a database call to retrieve the page object. Is there a downside to using this method though?
Thanks in advance!
$this->url('/path');
and
Loader::helper('navigation')->getLinkToCollection(Page::getByPath('/path'));
And in controllers, tools, etc. I've seen the navigation helper method above and also:
View::url('/path');
There might even be other methods that I'm leaving out.
So I'm wondering which method is best to use? I have to think using View::url() is more efficient since you don't have to load in the navigation helper and make a database call to retrieve the page object. Is there a downside to using this method though?
Thanks in advance!
If its within the site, I prefer to use the navigation helper.
Okay, cool. Is there any particular reason you prefer it? Like I said, it seems to me that it would have extra overhead since you have to pull the Page record from the database. I feel like I must be missing something.
Because it is the same process whether I have a URL, and ID or a page object to link to.
PS. Except when I need a controller action or tool.
PS. Except when I need a controller action or tool.