HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


How to create a link to a profile page

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#94211 (In Topic #18789)
Avatar

Community saint

Hi,

I would like to have a link on one page that jumps you to the logged on persons profile page, I tried the following but the $USERNAME does not get parsed and replaced and is taken literally - can any one point me in the right direction please ?

Code

[no_parse][page=":members:type=view:id={$USERNAME}"]Profile[/page][/no_parse]


Probably something really simple but I just cannot see it !!

Cheers,
Ade
Back to the top
 
Posted
Item has a rating of 5 (Liked by JeanLiked by Chris Graham)  
Rating:
#94213
Avatar

Community saint

I am assuming you don't want to individually edit the link for each member, simply have this link on the specific page so that clicking on it will take the user to that member's profile?

I don't know if this will work, but there's no harm in giving it a try …!!

Code

[page="site:members:type=view:rel=canonical"]{$USERNAME}'s Profile[/page]
I had to add 'site' to the page call and changed the 'id' to 'rel=canonical". And it works for ME.

Don't know whether it will fit in with your plans …!!

 :lol:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#94214
Avatar

Community saint

Superb as ever Fletch, works sweetly.

I cannot however find where these parameters to page are documented !!

Cheers
Ade
Back to the top
 
Posted
Rating:
#94215
Avatar

Community saint

Lhasadreams said

I cannot however find where these parameters to page are documented !!
Can't help you there, Ade. These 'suggestions' are a result of YEARS of ocPortal usage (in which you learn so many ways to skin the proverbial cat), and a very limited knowledge of HTML.

I readily admit that homing in on the 'rel=canonical' was a wild, wild guess, but it did the trick. Must file that away for MY future use!

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Item has a rating of 5 (Liked by sholzy)  
Rating:
#94218
Avatar

Community saint

Lhasadreams said

I cannot however find where these parameters to page are documented !!
I realise how unhelpful my previous answer must be for anybody following the thread, so I am adding the two obvious references, that I assume you have probably already looked at, but which might not have occurred to others …

and possibly one other 'Advanced' source that discusses the ocPortal API:

Hope that helps.

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#94241
Avatar

Fletch said

I am assuming you don't want to individually edit the link for each member, simply have this link on the specific page so that clicking on it will take the user to that member's profile?

I don't know if this will work, but there's no harm in giving it a try …!!

Code

[page="site:members:type=view:rel=canonical"]{$USERNAME}'s Profile[/page]
I had to add 'site' to the page call and changed the 'id' to 'rel=canonical". And it works for ME.

Don't know whether it will fit in with your plans …!!

 :lol:


":rel=canonical" not actually needed. "site:members:type=view" works on the basis that if no id parameter is given, it defaults to the currently logged in member. Actually, "site:members:view" would work too, that's shorthand.

Regarding the original post:
Explicitly using {$USERNAME} in the page-link was wrong for a couple of reasons. The first is that it should be the member ID (ocPortal will translate it in the actual generated URL based on the username for SEO purposes, but it's not a direct conversion, e.g. spaces would probably be converted to underscores). The second is that Comcode does not usually recognise symbols within Comcode tag parameters, as those are taken literally (as the original poster saw).

If you did want to put in the member ID explicitly, you could drop down to the level of Tempcode/HTML and define it like this:

Code

[semihtml]<a href="{$PAGE_LINK,site:members:view:{$MEMBER}}">{$USERNAME}'s Profile</a>[/semihtml]
Tempcode gives you more control, but is more complex.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#94249
Avatar

Community saint

Fletch said

I readily admit that homing in on the 'rel=canonical' was a wild, wild guess, but it did the trick. Must file that away for MY future use!

Chris Graham said

":rel=canonical" not actually needed. "site:members:type=view" works on the basis that if no id parameter is given, it defaults to the currently logged in member. Actually, "site:members:view" would work too, that's shorthand.
Thank you. Filed away for future reference.

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#94257
Avatar

Community saint

Cheers filed away as well !!
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Contract

Your name:
Your message: