Tempcode Identifiers Needed
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 page=topicview&type=view&id=655&keep_mobile=1&topic_start=0&wide_print=1 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:
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!
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 page=topicview&type=view&id=655&keep_mobile=1&topic_start=0&wide_print=1 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:
page=topicview&type=view&id=655&keep_mobile=1&topic_start=0&wide_print=1
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
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: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.
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.
Try the $_GET tempcode symbol: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 page=topicview&type=view&id=655&keep_mobile=1&topic_start=0&wide_print=1 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:
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!
From “Post #3346”, 12th Nov 2017
That should return the value of q and ignore any other variables.
Once again, you've saved the day Jason. Works like a charm – thanks man!
The use of {$LAST_VISIT_TIME} causes a critical error:
Fixed for next release.
https://github.com/ocproducts/composr/commit/7e103010b5e50fb1620981eefb066e63ebe14ddd
Is there a way of checking if the site is open or closed using Tempcode?
Yes, {$CONFIG_OPTION,site_closed} will be false (0) or true (1).
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 0 into an IF statement and surround the DIV containing this element so that it hides when the site is closed.
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 0 into an IF statement and surround the DIV containing this element so that it hides when the site is closed.
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)
Try this:
OPEN
OPEN
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}
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}From “News Images”, 24th Nov 2017
Haha, that was simple I guess. I was just overthinking it!
Question:
Why do some Tempcode identifiers have multiple variations with an asterisk or other symbol?
Example:
They seem to output the same though.
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.
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.
From “Post #3422”, 3rd Dec 2017
See "Escaping" section of Tempcode programming tutorial.
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:
..with no luck.
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.
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.
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.
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.
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.
{+START,IF_NON_EMPTY,{$FB_CONNECT_UID}}...{+END} should work.
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.
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.
{$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}.
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}.
0 guests and 0 members have recently viewed this.