Forum
Get site URL inside templates for share buttons
Is there a way to get the site URL inside a template for share buttons as twitter, facebook etc.? Found a way with php but dont seem like i can use php with templates?
Thanks in advance
Is there a way to get the site URL inside a template for share buttons as twitter, facebook etc.? Found a way with php but dont seem like i can use php with templates?
Thanks in advance
You can pass variables into templates, but it will not work with perch_content(). You would have to use perch_content_custom().
Or use:
Already tried that and it works, but i need to collect the slub as well. I have a created a list detail with undersites and slub from title. Is this possible?
I also found this snippet: <?php perch_page_url(); ?>. Obviously i need the template to be php instead of html, is that possible as well?
Yes, use PerchSystem::set_var() to pass it into the template.
How would you set up this if its the <?php perch_page_url(); ?> information i need to get into my template?
Thanks in advance
Then in template...
But you have to use perch_content_custom()
https://docs.grabaperch.com/docs/templates/passing-variables-into-templates/
I already got this.
Then all you need to do is follow the above and it will be working...
:)
Is this correct? Cant get it to work. I only get the domain name not the whole url. I get: https://mydomain.com/perch_page_url/
The url i need is https://mydomain.com/projects.php?s=projectname
Then you need to append the slug (s) to the url in your template. The "url" is simply the url. If you need additional quarry information appended then you have to append this in your template.
something like this...
Since I have never seen your actual template I have to generalize some of this, but enough is here to give a good idea of how this works.
:)
Yes, but still missing the projects.php in between.
With this code i get: https://mydomain.com/perch_page_url?s=projectname
What i need to get: https://mydomain.com/projects.php?s=projectname
Is my perch_page_url code wrong somewhere? Tried to replace with projects.php but dont like .'s very much. Not an php expert as you probably already noticed. Really appreciate all the help.
Is the perch content custom tag already on project.php? If yes, then all you need is a relative URL rather then the domain, file, stringed query.
Providing a complete template as well as the runtime function is very important in the beginning. Bits and pieces of code and templates makes solving issues like this very difficult.
I am glad to help but as much information as possible really helps.
Instead of:
You need
Actually i ended up with only getting the slug but the other way worked as well. Thanks!
If that's a new problem, please raise a new thread. This one is marked as solved, so we won't be able to try an new issue here.