Tempcode Identifiers Needed

Post

Posted
Rating:
#3341 (In Topic #655)
Joe
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=browse&id=deploying/tempcode-identifiers&post_id=3417&redirected=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=browse&id=deploying/tempcode-identifiers&post_id=3417&redirected=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

Post

Posted
Rating:
#3342
Joe
Also,

The use of 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

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Chris Graham)
#3345

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)

Open Source CMS with advanced social, interactive and dynamic features. Fully flexible, themeable and extendible: suitable for building powerful websites.

View



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 page=topicview&type=browse&id=deploying/tempcode-identifiers&post_id=3417&redirected=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=browse&id=deploying/tempcode-identifiers&post_id=3417&redirected=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!
Try the $_GET tempcode symbol:

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

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Jason Verhagen)
#3348
Joe
Once again, you've saved the day Jason. Works like a charm – thanks man!

Post

Posted
Rating:
#3350
The use of {$LAST_VISIT_TIME} causes a critical error:

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

Post

Posted
Rating:
#3375
Joe
Is there a way of checking if the site is open or closed using Tempcode?

Post

Posted
Rating:
#3376
Yes, {$CONFIG_OPTION,site_closed} will be false (0) or true (1).

Post

Posted
Rating:
#3377
Joe
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.

Post

Posted
Rating:
#3378
Joe
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)

Post

Posted
Rating:
#3379
Try this:



OPEN

Post

Posted
Rating:
Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 Item has a rating of 5 (Liked by Jason Verhagen)
#3380
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}

Post

Posted
Rating:
#3381
Joe

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!

Post

Posted
Rating:
#3416
Joe
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.

Post

Posted
Rating:
#3417

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.

Post

Posted
Rating:
#3439
Joe
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.

Post

Posted
Rating:
#3440
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.

Post

Posted
Rating:
#3461
Joe
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.

Post

Posted
Rating:
#3462
{+START,IF_NON_EMPTY,{$FB_CONNECT_UID}}...{+END} should work.

Post

Posted
Rating:
#3489
Joe
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.

Post

Posted
Rating:
#3490
{$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}.
1 guest and 0 members have recently viewed this.