[personal profile] ex_awakened208 posting in [community profile] style_system
Is it possible to create a custom text module for a community that is only visible to members of that community?

Date: 2012-04-09 02:11 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
Definitely possible with a custom layer. Would that be a second module or a replacement of the existing custom text module?

Replacing the existing module

Date: 2012-04-09 07:47 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
No problem.
So, if you need just the one module, this replaces the existing one and makes it so that only members can see it:

function print_module_customtext() {
    var Page p = get_page();
    if (viewer_is_member()) {
        open_module("customtext", $*text_module_customtext, $*text_module_customtext_url);
        print safe $*text_module_customtext_content;
        close_module();
    }
}


You would customize title and content in Customize as usual. (BTW, I don't know if you need help with layers so I haven't explained about them but I can if you need me to).

Adding a second module, tied to the first one

Date: 2012-04-09 07:51 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
If you want to display two modules but have the second one only visible to members, you'd use this instead:

function print_module_customtext() {
    var Page p = get_page();
    open_module("customtext", $*text_module_customtext, $*text_module_customtext_url);
    print safe $*text_module_customtext_content;
    close_module();

var string title = "Members-Only";
var string title_url = "htpp://myurl.com";
var string content = """Content only visible to members""";

    if (viewer_is_member()) {
        open_module("customtext2", $title, $title_url);
        print safe $content;
        close_module();
    }
}


You'd customize title and content in Customize for the first module but would need to edit title, title_url (or blank it) and content in the code above for the second, 'hidden' module.

Re: Adding a second module, tied to the first one

Date: 2012-04-09 08:00 pm (UTC)
ninetydegrees: Art: self-portrait (Default)
From: [personal profile] ninetydegrees
You're most welcome!

One more thing: In the code above, the CSS class for the second module is .module-customtext2 (that's the first variable in open_module). If the custom text module has some existing styling it would be better to leave it to the usual 'customtext' so the styling applied to both modules. If you want to be able to CSS style the second module differently, you can add a second class by changing the name to 'customtext membersmodule'. However, if you used .membersmodule in your CSS customizations, keep in mind that any code savvy person would deduce this module existed if they looked at the CSS for the journal.
Edited Date: 2012-04-09 08:00 pm (UTC)

Profile

Dreamwidth style system discussion

July 2025

S M T W T F S
  123 45
6789101112
13141516171819
20212223242526
2728293031  

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 10th, 2025 01:46 pm
Powered by Dreamwidth Studios