Share a template
I am trying to share an article (based on a template) on Facebook. How can I add the id to the page path? The id is:
id="article_<perch:content id="perch_item_index" type="hidden" />"
The link to the page is:
<a href="https://www.facebook.com/sharer/sharer.php?u=https://www.domain.com<?php echo PerchSystem::get_page(); ?>">Share on FB</a>
Thanks a lot!
perch_item_index
won't give you a unique ID. Use_id
instead.First I should add the page id too, then the template id. I tried this, but it doesn't work:
Where did that code come from?
Maybe my approach is wrong. I wanted to reuse the code I have for sharing a page (see my first thread). But in that case the page and the article both are templates. Maybe there is a better way to share an article from a perch template?
What end result are you trying to get to?
I want to share articles on Facebook. The articles are based on a Perch template as well the page.
What HTML are you trying to output? Please give an example so that I know what you're trying to do.
Here is an example of a path to an article: https://www.domain.com/news/news1.php#news_1
The page and the article are Perch templates.
Ok, great. What information do we have in the environment to locate the article?
This is the container of the article:
You could do something like:
This is fine to get to the right article. But as the page name is also from a template I need to add this too. <perch:pages id="pageNavText"/> does not output it, it's empty before «.php».
perch:pages
tags will only work in a navigation template - not a content or blog template.I was trying to use: perch_pages_navigation_text() but it's wrong, too. How should I do it? Thanks for your help!
I'm confused. Are you doing this in a template or in the page? Do you know the page path, or do you need to figure it out? There's so much confusing information and guesswork here that I'm not clear on what we're actually trying to achieve. I don't think it's anything complex!
Sorry, I try to clear this: the articles I'd like to share on Facebook finally are a template. That's what we have figured out already: <perch:content id="_id" type="hidden" />. The second thing is, I need to get the page name. (The articles are in a template page.) So the question is how I get the «pageName» in the path?
I agree with you, it couldn't be difficult... Your help is much appreciated!
The page name or the path?
The page name!
You can use
perch_pages_title()
for that:https://docs.grabaperch.com/functions/navigation/perch-pages-title/
I had this before, but all formats I tried were wrong. How is it correct, please?