• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Can someone tell me how to use jquery to replace the "No one logged in" message generated from {modu

New Here ,
Apr 29, 2013 Apr 29, 2013

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

TOPICS
How to

Views

1.7K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 29, 2013 Apr 29, 2013

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 29, 2013 Apr 29, 2013

Copy link to clipboard

Copied

Thanks Chad, much appreciated... I'll give it a go

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 01, 2013 Jul 01, 2013

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 02, 2013 Jul 02, 2013

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jul 02, 2013 Jul 02, 2013

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Jul 02, 2013 Jul 02, 2013

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";

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 11, 2014 Sep 11, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 17, 2014 Sep 17, 2014

Copy link to clipboard

Copied

LATEST

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}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines