inherit
269306
0
Apr 22, 2024 23:29:28 GMT -8
pw121
12
April 2024
pw121
|
Post by pw121 on Apr 17, 2024 4:15:44 GMT -8
Forum URL: cityofcursedgods.freeforums.netOk, so I’m trying to make a zone that shows one html code if the user is a guest. Otherwise, the other html code appears. You can see the problem if you click that and see the top zone. It will show two things. My code: <if $[current_user.is_guest] ='false'> City of Cursed Gods is an isometric turn-based strategy game about your faction growing and developing to conquer dfferent mercenary factions. Your faction can trade with other factions and help other factions. Equip and level your warriors, then you're off to battle other factions in Skirmish or Campaign mode. <br> <br> Here is the largest CoCG community - completely free to join and in your <b> grasp</b>! Talk and play when you feel like it - you decide! <br> <br> If you're unsure what to do next, check out the <a href="/page/userguide"> user guide!</a> <br> <br> </if> <if $[current_user.is_guest] ='true'> City of Cursed Gods is the largest CoCG community where you can chat with other gamers. It's completely free and in your grasp! Talk and play when you feel like it - you decide! <br> <br> If you need help with anything, check out the <a href="/page/userguide"> user guide</a> for more information on certain aspects of the site! Also join the free Discord Server! </if> code here It shows either one even if you are a guest or a member. Could someone help me? Thanks in advance!
|
|
#e61919
Support Staff
224482
0
1
Apr 30, 2024 17:07:50 GMT -8
Scott
23,315
August 2015
socalso
|
Post by Scott on Apr 17, 2024 6:08:18 GMT -8
pw121 - Use this: {if $[current_user.is_guest]} TEXT FOR GUEST HERE {else} TEXT FOR MEMBER HERE {/if}
|
|
inherit
217348
0
Jul 27, 2022 7:26:44 GMT -8
Lynx
5,781
January 2015
msg
|
Post by Lynx on Apr 17, 2024 8:02:04 GMT -8
The main problem here is that template variables, such as the $[current_user.is_guest] you used, don't work on custom pages (which is where you're trying to get the code to work, according to your thread title). Template variables are only valid in the template they're for (some are template-specific, a few are somewhat global).
You'll most likely need to use some JS to accomplish what you want on the page. You can use pb.data('user').is_logged_in to see if it's a guest or not.
EDIT: I'll see if I can throw together a script sometime today that you can use.
My bad. Ignore my post.
|
|
#e61919
Support Staff
224482
0
1
Apr 30, 2024 17:07:50 GMT -8
Scott
23,315
August 2015
socalso
|
Post by Scott on Apr 17, 2024 8:27:41 GMT -8
Lynx - Global Variables do work on custom pages. The template variable being used is Global.
|
|
inherit
269306
0
Apr 22, 2024 23:29:28 GMT -8
pw121
12
April 2024
pw121
|
Post by pw121 on Apr 17, 2024 13:09:32 GMT -8
pw121 - Use this: {if $[current_user.is_guest]} TEXT FOR GUEST HERE {else} TEXT FOR MEMBER HERE {/if} Thanks for the reply! But for some reason it’s still not working
|
|
inherit
269306
0
Apr 22, 2024 23:29:28 GMT -8
pw121
12
April 2024
pw121
|
Post by pw121 on Apr 17, 2024 13:14:29 GMT -8
pw121 - Use this: {if $[current_user.is_guest]} TEXT FOR GUEST HERE {else} TEXT FOR MEMBER HERE {/if} It seems to show on the page (the code) but not actually trigger
|
|
#e61919
Support Staff
224482
0
1
Apr 30, 2024 17:07:50 GMT -8
Scott
23,315
August 2015
socalso
|
Post by Scott on Apr 17, 2024 13:40:15 GMT -8
pw121 - The issue is putting it in a widget. 1. Edit the custom page and instead of the Visual Editor tab, click on the HTML tab. 2. Replace lines 2 thru 4 with this: <div class="container"> <div class="title-bar"> <h2>About City of Cursed Godes</h2></div> <div class="content" style="padding:10px;"> {if $[current_user.is_guest]} TEXT FOR GUEST HERE 2 {else} TEXT FOR MEMBER HERE 1 {/if} </div> </div> 3. Add your custom guest/member text and click the Save Changes button.
|
|
inherit
269306
0
Apr 22, 2024 23:29:28 GMT -8
pw121
12
April 2024
pw121
|
Post by pw121 on Apr 17, 2024 13:48:46 GMT -8
Scott, thanks so much! It worked and now guests will see a free to join section while members see a “what to do next” section.
|
|