Copy link to clipboard
Copied
I need to replace the "No one logged in" boilerplate text that {module_whosloggedin} generates with French "Non connecté"
I understand jquery is the best way to do this but I need help with a code sample.
thanks
Copy link to clipboard
Copied
Hello Doug McLachlan,
Depending how you have your HTML, you can do this with jQuery or CSS.
In the CSS method you would just add that is logged in module to the class of the div: <div class="user-{module_isloggedin}"></div> - Then in your CSS display none on the user-0 class.
The jQuery method is similar, you're just checking if the isloggedin module is a one or zero, then using jQuery to hide or show.
To just replace the text with nothing using jQuery would be something like this: http://jsfiddle.net/chaddidthis/4TQeV/
Hope this helps,
Chad Smith - BC Gurus
Copy link to clipboard
Copied
Thanks Chad, much appreciated... I'll give it a go
Copy link to clipboard
Copied
Thanks Chad. The CSS things is both obvious (now that you mention it) and brilliant.
So here's my example for swapping out text, rather than making it visable/invisable, for anyone trying the same thing in the Online Shop module for small_product.html.
HTML:
<h4><span class="public-price-{module_isloggedin}">Note: </h4>
CSS:
.public-price-1:after {
content:"Special member only price";
}
.public-price-0:after {
content:"Sign-in for special member only price - Membership is free";
}
Note: For :after to work in IE8, a <!DOCTYPE> must be declared in your HTML doc. e.g. <!DOCTYPE html> for the head tag.
Copy link to clipboard
Copied
Simon,
That too is brilliant! I always forget about the many pseudo classes that are available to us. They can truly make your life easier.
Thanks,
Chad Smith
Copy link to clipboard
Copied
Great solution! Should note though that this won't work in IE less than 8 but those browsers are losing their market share pretty fast. If you need to support less than IE8 you should use a javascript solution.
Also, you forgot to close your <span> in your <h4>. I only mention it because its a matter of time before someone tries to replicate your solution and runs into that problem.
Nice work, though! I too need to start using pseudo classes more since IE8 does support them. For years I was avoiding them entirely because of lack of support and I need to keep reminding myself to start using them more.
Copy link to clipboard
Copied
Oh yes, thanks. I better correct that...
So here's my example for swapping out text, rather than making it visable/invisable, for anyone trying the same thing in the Online Shop module for small_product.html.
HTML:
<h4><span class="public-price-{module_isloggedin}">Note: </span></h4>
CSS:
.public-price-1:after {
content:"Special member only price";
}
.public-price-0:after {
content:"Sign-in for special member only price - Membership is free";
}
Copy link to clipboard
Copied
Thanks for this discovery, I've been pulling my hair out to get a logged-in / not-logged-in dynamic driving some basic content
Is it true I would need to adopt a javascript method to include a link to my sign in page in the 0 content " " ?
thanks so much
Copy link to clipboard
Copied
Let me add that you also need to add a css rule for "user-" as well. Sometimes the system does not display the "0"
.user-,.user-0{display:none}