Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi!

On the website I'm working on, I have a blog and a profile directory.

I need to link the blog and profile template, so that it detects if the "author_name" in the blog template matches a name in the profile template, it links the "author_name" to his profile, and also I need to show the profile picture of the author, also coming from the profile template.

What I tried is :

Code: Select all
<cms:set author_name="<cms:show author_prenom/> <cms:show author_nom />"/>
<cms:pages masterpage='profile.php'>
<cms:set get_name="<cms:show profile_prenom/> <cms:show author_nom />" />
<cms:if author_name == "<cms:show get_name/>" >
<h3> Author name : <a href="<cms:show k_page_link />">click</a></h3>
<cms:show profile_photo />
<cms:else />
<h3> Not working </h3>
</cms:if>
<cms:show author_name/>
</cms:pages>


So I'm setting the variable outside of the masterpage="profile.php" scope.
author_prenom and author_nom are the 2 fields from the blog template that I have to enter in the admin section, to tell who wrote the article.

Then, I tried to tell couchcms to verify :
if author_name (from blog) matches "profile_prenom + profile_nom" (from profile), then it shows adds the link to his profile, and his profile photo.

How should I do this? Thanks!
I've found a way to make it work, but now the issue is that I'm using "page_name" for the masterpage parameter, but I can't seem to be using a variable inside "page_name".

I've set this variable :

Code: Select all
<cms:set author_name_url="<cms:show author_prenom />-<cms:show author_nom />"/>


and I would like it to be the page_name value :

Code: Select all
<cms:pages masterpage='profile.php' page_name="author_name_url">


But it's not working. What am I doing wrong?
@larin555, in the double quotes you may use an expression ("<cms:show .. />" )or a string "some string". Passing a variable should be without double quotes. page_name=somevariable or it will be wrongly taken as a string or expression.
Join COUCH:TALK channel here https://t.me/couchcms_chat
Ryazania — a framework to boost productivity with Add-ons viewtopic.php?f=2&t=13475
Support my efforts to help the community https://boosty.to/trendo/donate
@trendoman answered this query as I was preparing my reply. I'll post it anyway :)

Hi,

Instead of the current -
Code: Select all
<cms:pages masterpage='profile.php' page_name="author_name_url">

- please try using this
Code: Select all
<cms:pages masterpage='profile.php' page_name=author_name_url>

The first version above is using double quotes which will make Couch search literally for a page named "author_name_url". Please see http://docs.couchcms.com/concepts/setti ... eters.html if you are unclear about the use of quotes/double-quotes.

That said, for linking together pages from two templates we have more powerful methods at our disposal. Please see http://docs.couchcms.com/concepts/relationships.html

Hope it helps.
4 posts Page 1 of 1