I’ve been googling for a while and found nothing so I’m hoping someone here will have an idea.
I’m trying to get the current page id from inside a SS template. Essentially I’m looking for a function or variable to place inside the <% %> tags of the .ss file that will return the id of the page currently being viewed.
Thanks for your response. I have tried this but it just throws an error:
“Unexpected problem parsing template”
It’s probably worth noting that I’m working on a component that is added as an include to a page. Essentially what the component does it get a list of 3 related articles however the first of these related articles is always the same as the current article being viewed so I’m trying to exclude it.
Just to clarify, you just need $ID in the template, not <% $ID %>
But, if you’re pulling in content from a method in your PHP, then it might be better to just put the logic in there, rather than the template (psuedo-code below):
public function getRelatedArticles() {
return Article::get()->exclude([
'ID' => $this->ID
]);
}
(obviously the logic in that would need to be made right for your application)