Tempcode Identifiers Needed

Post

Posted
Rating:
#3346 (In Topic #624)
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
I'm working on a custom members area that displays all data of a member in one area. So far I've been successful at pulling most profile information – there's just a couple things I can't seem to figure out.

How to pull the members…
Post count?
Topic count?
Signature?

How can I pull this info using Tempcode? I didn't find anything in the Tempcode tutorial on how to achieve this.

Also, I need to be able to strip down a query string to only display parts of it. Here's an example:
User visits ?q=testvalue, I want to be able to remove '?q=' from that string

I'm using {$QUERY_STRING} but that returns q=testvalue (it just removes ? and everything before it)

EDIT: I used the following which seems to work, but not quite how I expected:

{$REPLACE,q=,,{$QUERY_STRING}}

This does work, but only if the user requests that string and that string alone. If others are passed in the URL, it's a mess. Is there a more effective way of doing this? To maybe 'dissect' the URL and only return the requested string instead of all the strings?

Thanks!

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
#3347
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Also,

The use of {$LAST_VISIT_TIME} causes a critical error:

PHP ERROR [1] Call to undefined function cns_read_in_member_profile() in sources/symbols2.php on line 2120

EDIT: weirdest thing, but it's not producing this error anymore!

Last edit: by Joe

Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Chris Graham)
#3350
Avatar
Standard member
Jason Verhagen is in the usergroup ‘Community saint’

Joe said

I'm working on a custom members area that displays all data of a member in one area. So far I've been successful at pulling most profile information – there's just a couple things I can't seem to figure out.

How to pull the members…
Post count?
Topic count?
Signature?

How can I pull this info using Tempcode? I didn't find anything in the Tempcode tutorial on how to achieve this.
These bits of info will probably need custom tempcode symbols created. If you can follow and write some PHP code, the documentation for this is here: Code Book, part 1b (Further back-end concepts) - Composr

Check the sources/hooks/systems/symbols and sources_custom/hooks/systems/symbols directories for examples of how new symbols are coded. Any symbols you create should be placed in the sources_custom/hooks/systems/symbols directory (create it if it doesn't exist). If you can follow the existing Composr code, you would need to find the parts of the code that generate the info you are wanting in the scripts that generate the profile tabs (should be found in sources/hooks/systems/profile_tabs) and integrate those bits of code into your new symbols code files.

Joe said

Also, I need to be able to strip down a query string to only display parts of it. Here's an example:
User visits ?q=testvalue, I want to be able to remove '?q=' from that string

I'm using {$QUERY_STRING} but that returns q=testvalue (it just removes ? and everything before it)

EDIT: I used the following which seems to work, but not quite how I expected:

{$REPLACE,q=,,{$QUERY_STRING}}
This does work, but only if the user requests that string and that string alone. If others are passed in the URL, it's a mess. Is there a more effective way of doing this? To maybe 'dissect' the URL and only return the requested string instead of all the strings?

Thanks!
Try the $_GET tempcode symbol: {$_GET,q}

That should return the value of q and ignore any other variables.

Regards,
Jason


My ocPortal Sites: Holleywood Studio / Tech Fusion Online
My Composr Sites: NEWBotics Labs
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Jason Verhagen)
#3353
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Once again, you've saved the day Jason. Works like a charm – thanks man!
Online now: No Back to the top

Post

Posted
Rating:
#3355
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
The use of {$LAST_VISIT_TIME} causes a critical error:

Fixed for next release.
https://github.com/ocproducts/composr/commit/7e103010b5e50fb1620981eefb066e63ebe14ddd


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3381
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Is there a way of checking if the site is open or closed using Tempcode?
Online now: No Back to the top

Post

Posted
Rating:
#3382
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Yes, {$CONFIG_OPTION,site_closed} will be false (0) or true (1).


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3383
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Thanks Chris, but how can I implement that into an IF statement if true or false?

Basically what I'm trying to do is hide main_website_inner when the site is closed, so only the box and closed message displays.

I could put {$CONFIG_OPTION,site_closed} into an IF statement and surround the DIV containing this element so that it hides when the site is closed.
Online now: No Back to the top

Post

Posted
Rating:
#3384
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
I did try a few things, but none seemed to work

Code

{+START,IF,{$CONFIG_OPTION,site_closed,1}}CLOSED{+END}
{+START,IF,{$CONFIG_OPTION,site_closed,0}}OPEN{+END}

{+START,IF,{$CONFIG_OPTION,site_closed},1}CLOSED{+END}
{+START,IF,{$CONFIG_OPTION,site_closed},0}OPEN{+END}
(returns both)

Code

{+START,IF_PASSED_AND_TRUE,{$CONFIG_OPTION,site_closed}}CLOSED{+END}

{+START,IF_NON_PASSED_OR_FALSE,{$CONFIG_OPTION,site_closed}}OPEN{+END}
(returns open, even when site is closed)
Online now: No Back to the top

Post

Posted
Rating:
#3385
Avatar
Standard member
Jason Verhagen is in the usergroup ‘Community saint’
Try this:

{+START,IF,{$EQ,{$CONFIG_OPTION,site_closed},1}}CLOSED{+END}

{+START,IF,{$EQ,{$CONFIG_OPTION,site_closed},0}}OPEN{+END}

Regards,
Jason


My ocPortal Sites: Holleywood Studio / Tech Fusion Online
My Composr Sites: NEWBotics Labs
Online now: No Back to the top

Post

Posted
Rating:
Item has a rating of 5 (Liked by Jason Verhagen)
#3386
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Jason's will work, but it can be simpler…

Code

{+START,IF,{$CONFIG_OPTION,site_closed}}CLOSED{+END}

{+START,IF,{$NOT,{$CONFIG_OPTION,site_closed}}}OPEN{+END}


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3387
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’

Chris Graham said

Jason's will work, but it can be simpler…

Code

{+START,IF,{$CONFIG_OPTION,site_closed}}CLOSED{+END}

{+START,IF,{$NOT,{$CONFIG_OPTION,site_closed}}}OPEN{+END}

Haha, that was simple I guess. I was just overthinking it!
Online now: No Back to the top

Post

Posted
Rating:
#3422
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Question:

Why do some Tempcode identifiers have multiple variations with an asterisk or other symbol?

Example:

Code

{$COPYRIGHT}, {$COPYRIGHT`} | {$USERNAME*}, {$USERNAME}

They seem to output the same though.
Online now: No Back to the top

Post

Posted
Rating:
#3423
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’

Joe said

Question:

Why do some Tempcode identifiers have multiple variations with an asterisk or other symbol?

Example:

Code

{$COPYRIGHT}, {$COPYRIGHT`} | {$USERNAME*}, {$USERNAME}

They seem to output the same though.

See "Escaping" section of Tempcode programming tutorial.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3445
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
Is there a way to check if the current user has a highlighted username?

I'm trying to expand this functionality to appear in more areas than just on the forums.

The forum posts template uses {+START,IF_PASSED_AND_TRUE,HIGHLIGHT_NAME}{+END} but when I use that on other areas of the site it doesn't work.

I've also tried:

Code

{+START,IF_NON_EMPTY,HIGHLIGHT_NAME}{+END}, {$CPF_VALUE,Highlighted name}

..with no luck.
Online now: No Back to the top

Post

Posted
Rating:
#3446
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
Template parameters only will work in the template they are passed into.

Symbols and directives will work anywhere, so long as they don't depend on the aforementioned parameters.

{$CPF_VALUE,m_highlighted_name} should work. It's not documented (I'll correct that), but this symbol supports almost any field from the f_members table as well as CPFs.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3467
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
How about one to tell if the current user is a Facebook login? I thought I seen an identifier for that somewhere but I can't seem to find it now.

I'm detailing some member-specific features using icon links; one is the ability to change their username/display name but this feature isn't available for FB accounts, so I want to hide this icon entirely for FB accounts.
Online now: No Back to the top

Post

Posted
Rating:
#3468
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
{+START,IF_NON_EMPTY,{$FB_CONNECT_UID}}...{+END} should work.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top

Post

Posted
Rating:
#3495
Joe
Avatar
Standard member
Joe is in the usergroup ‘Honoured member’
According to the Composr docs, {$DATE} has optional parameters that aren't detailed there. What are they?

I'm giving a payment example on my site. The example will take the current month and day (maybe there's some parameters I can use to extract the current day number and the current month), add 30 (using {$ADD}) and give the date of a next payment (since payments are due every month).

Of course telling people the payment is due every month would be the easiest solution, but I suspect some will complain about not knowing the exact (or close) date of when a new payment will be required. In addition, I'll be giving examples of prorations that would be issued if they cancelled on such and such dates (this is the advanced part, I think I can figure this out).

Now there's the issue of some months having 28-31 days. I think it would be cool to implement something that takes this into account, but if it's too complex then I'll just use 30 in my examples to give a general idea.
Online now: No Back to the top

Post

Posted
Rating:
#3496
Avatar
Site director
Chris Graham is in the usergroup ‘Administrators’
{$DATE,use_contextual_dates=0|1,verbose=0|1,server_time=0|1,timestamp,member_id}

use_contextual_dates means like 'Today', 'Yesterday'.

verbose uses the verbose language strings which present long-form dates.

server_time means in the server's own timezone, rather than the current user.

timestamp is a unix Timestamp. If not given it will be the current time.

member_id is the member who's timezone to use (if not just the current user's).

{$FROM_TIMESTAMP,format_string,timestamp}

format_string is as per PHP's strftime function.

timestamp is a unix Timestamp. If not given it will be the current time.

You probably want FROM_TIMESTAMP.

I'm not sure how "adding 30" would give you the end of the month. I think you actually want something like {$MAX,{$FROM_TIMESTAMP,%d,{TIMESTAMP},30}.


Become a fan of Composr on Facebook or add me as a friend. Add me on on Mastodon. Follow me on Minds (where I am most active). Support me on Patreon

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 Composr whenever you see the opportunity or support me on Patreon.
  • 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 Composr 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.
Online now: No Back to the top
1 guest and 0 members have just viewed this.
Back to Top