Wiccle.com in Facebook Wiccle.com in Twitter Wiccle.com in LinkedIn Wiccle.com in Youtube RSS from Wiccle.com Wiccle.com in Atom
 
 
 

Thread: Customizing content for members: Tags, conditionals and include files

Started: February 26, 2010, 10:12 PM  ⋅  Zone: Public Forums  ⋅  Category: Install & Modification  ⋅  Posts: 5  ⋅  Views 755
Started by: john  ⋅  Description: Was: Customizing box header.
Post #1
Member: john  ⋅  Date: February 26, 2010, 10:11 PM  ⋅ Subject: "Customizing box header."

Hi Markus,

I'm trying to customize the first header on my home page to display a personalized message for the member logging in:

I tried using MEMBER_DISPLAY_NAME and MEMBER_UNREAD_MAIL in place of the brackets above - I thought it had worked but it showed the Admin's name and Admin's unread message count regardless of who the logged-in member was.

How can I achieve the above?

Thanks for your help.

Post #2
Member: Markus  ⋅  Date: February 27, 2010, 01:06 AM  ⋅ Subject: "Re: Customizing box header."

I have set up a new page to the demo where this is shown in action. Please see here for how to create personalized notes in your custom content units, including the unit headers.

Now, if you wanted to go wild, you could combine that with templating script and conditionals... Unfortunately the member details are currently parsed in at the very end across all data, while the conditionals evaluate as the unit is first processed, so the following will not work right now. Making the following work with member data as well is but a little tweak away, and if there's interest I can add it in for the next release.

<#IF:EMPTY:MEMBER_CURRENT#>You've been lazy! Your current status is all blank!</#>
<#IF:NOT_EMPTY:MEMBER_CURRENT#>You're a good citizen! You have a status message saying [
[
MEMBER_CURRENT]]..."!</#>

Our top level scripting works both in dynamic templates as well as in the custom data an administrator adds in. Likewise, you can use most language strings (as you may have noticed from some of the language tags used as unit custom headers since 1.20) in what you input into the system. You can look  up more tags in validate_conditionals() under class_templates.php.

Be aware that TinyMCE currently breaks our template script as it attempts to evaluate it as HTML. If you hack around with conditionals as above, you will need to do it without the WYSIWYG editor. I have some sort of simple workaround in place for my own purposes (and included in 1.2x), but it's far from perfect in making TinyMCE work with this as it's meant to.

Post #3
Member: john  ⋅  Date: February 27, 2010, 01:31 AM  ⋅ Subject: "Re: Customizing box header."

This is seriously good stuff!

Thanks Markus.

Post #4
Member: Markus  ⋅  Date: February 27, 2010, 01:51 AM  ⋅ Subject: "Re: Customizing box header."

By the way, if you want to do a bit more customizing before you output things, you can use <#INCL:my_custom_message.php#></#> (for example), and place a file into under /templates/includes/ where you just stick whatever you want to output under the variable $ext_input.

I frequently use this instead of attempting to tweak things together with the editor when I need to copypaste a large chunk of HTML, or if I need to do some simple evaluations before the content is printed out. Also, it's a sure way to keep less educated customers from messign things up. It's also an easy way to duplicate the same content in different units across pages without adding the info in several times. (Still working on "sticky" units that can be copied via builder, and there are the widgets too of course.)

If you used the above approach, you could do for example the following:

Create a blank file called my_mail_status.php. Inside it, place (for example) the following PHP code:

/* Here we evaluate the amount of a member's new mails */

if ($_SESSION['member']['member_unread_mail'] == 0)
       $msg = "What a shame! No new mails today!";
elseif ($_SESSION['member']['member_unread_mail'] == 1)
       $msg = "Grand! You got one new mail!";
else
      $msg = "You're getting lots of mail these days! (Total {$_SESSION['member']['member_unread_mail']})";

/* Here we stick the message under the correct input variable to get everything passed onward */

$ext_input = <<<
<div class="general_wrapper">
   <h3>Your Mail Status Report</h3>
    <p>{$msg}</p>
</div>
WIC;

That gives you more control over what happens than hacking something like this together with the handy albeit limited template script would, since you have all the freedom of PHP at you disposal. Here's the above in a sample file you can grab and use or modify if you want to.

If you wanted to access all the data in the current unit that's being parsed (from your custom content to all of its builder choices to its database ID), it would be available to you under the variable $cache['current']['unit'] all across the system. (And for the current layout, it'd be under 'layout'.) You could for example check: if ( strstr($cache['current']['layout']['lay_ident'], "hello") === TRUE) ... else ... and then have the same bit on different pages, but make it behave one way on pages that have "hello" in the "show" variable of the URL, and another way for the rest of your pages.

If you wanted to include a little script such as above and create a unit that is visible only in certain situations (for example when new mail is available), you could declare $cache['current']['hide_this'] = true; after checking that mail counter is at zero, as we did above, and the unit would get hidden on the fly.

Since you're into usability, and you know your member base well, you could for example have a basic version of a message in $ext_input, a more verbose and elaborate version specifically for grandpa: if ($_SESSION['member']['member_username] == "Grandpa" || $_SESSION['member']['member_username] == "Grandma") $ext_input .= "Hey grandpa and grandma! Here's something more for you." --- how about that!

Or you could check, if ( (date("G") > 22 || date("G") < 7) && $_SESSION['member']['member_username] == "Little Jimmy") $ext_input = "Bedtime for kids! Check again tomorrow at seven.";

And if you should choose to tweak around with any of the above, I definitely want to hear what you've been up to! Cool

Post #5
Member: Markus  ⋅  Date: February 27, 2010, 02:06 AM  ⋅ Subject: "Re: Customizing content for members: Tags, conditionals and include files1"

Looking forward seeing what happens! We have lots of powerful stuff in the system allright. We've actually had the templating script in since version 1.00... The include feature was something we rolled in with 1.20, even if it's been here in internal use for a small forever as well.

You won't be able to break anything no matter how much you experiment with any of the above. (Unless you do exec("format c:") or some such Laughing but that's quite beyond my control!)

It's again this time of the night, and while I should either be working or sleeping, I'm yapping away at the forums! Cool I'll go and grab a beer at our friendly hotel next door to wind things up and call it a day for now. We've had a mad level of production going on here, and it's rolling on. Here's one of the many new sites in works that went live today: EcoWallTherm Insulation Professionals from co. Galway. They liked both the site as well as the Wiccle crash-course for updating their site. We have lots of happy customers here!

Cheers! As they say in Ireland. (I guess they say it elsewhere too --- it's just that I've never been saying that in the past. Picking up the local talk!)

 

Install & Modification

Add to Favorites
Public Forums
Category  ⋅  Deploying iWiccle and Wiccle into unique solutions that match your needs.
 

Public Forums

Add to Favorites
Public Forums
Zone  ⋅ Public forum sections for support and discussions. Available for everyone.
 

Zone Categories

 
Questions? Ask us!
Back to Top