Who We Are
bmk
girlie
kristine
Search



Notify List
Let us keep you posted on new entries! Join the notify list!
Blog Status
14 entries
146 comments
12.06.04 11:44 am last update
last 50 referrers

Listed on BlogShares
Syndication
link to us!

virtual venus

virtual venus: MT Wiki
Powered By
because weblogs need love too
Saturday, October 25, 2003
Restricted Portions of Posts

This is a little something I did for fun as a companion to the ScriptyGoddess Restricted Access Posts hack.

Due to a situation I won't bother going into detail on, I started thinking about how I might protect certain text within the entries on my journal. I already use the SG hack to protect entries which I place in a restricted category, so I began looking at that code to see how I could adapt it to recognize that I wanted certain pieces of text within an otherwise unrestricted entry to not display unless the user already had access to the completely restricted entries on my site.

Are you with me so far? Say I have an entry with text like this:

There are a lot of coworkers who I do not like.

For example, that bitch Angela drives me nuts.

But I have learned to get along with everyone.
Maybe I don't want just anyone who runs across my journal to see my statement about Angela (especially Angela if she knows her way around Google).

So this is what I came up with.

Required: the Process Tags plugin (and of course, the aforementioned SG hack already installed on your site)

I first created two new Template Modules, begin_restricted and end_restricted:

begin_restricted

<?
$accessallowed = FALSE;

if (in_array($ip, $array, TRUE) || in_array($cookievalue, $array, TRUE))
{
$accessallowed = TRUE;
}

if ($accessallowed)
{
PRINT "

end_restricted

";
} ?>

These are the pieces of code taken (and modified) from the SG hack.

Then, I invoked the process tags plugin within the Individual Entry Archive:

<MTEntryBody process_tags="1">
<MTEntryMore process_tags="1">

The only thing left to do is call the modules in my entry around the restricted text:

There are a lot of coworkers who I do not like.

<MTInclude module="begin_restricted">

For example, that bitch Angela drives me nuts.

<MTInclude module="end_restricted">

But I have learned to get along with everyone.
Now, when I publish the entry, the Process Tags plugin pulls in the necessary PHP code to block the display of my insult to Angela if the reader doesn't have the cookie from the SG hack which gives them full access to my journal:
There are a lot of coworkers who I do not like.

But I have learned to get along with everyone.
That's all they see. View Source merely displays some empty <p> and </p> tags, due to MT's Convert Breaks formatting option.

I could probably also use an ELSE statement to alert them to the restriction, offer access, etc., but I think that's more distraction than I want to insert into my entries. Perhaps for larger blocks of text, I'll create some alternate modules with these options; or explain elsewhere on my site about the restricted access feature.

Also, I could have avoided the plugin altogether and just used PHP includes for the two pieces of code, but I decided it would be easier to remember the module names than the full path to the files every time I wanted to use them.

I do have to be careful with this, of course - blocking too much might cause the entry to not make sense to the reader who doesn't have full access. But I just wanted to see if I could figure out how to do it; whether I actually make use of it or not remains to be seen.

Perhaps there's a way to achieve this purely in PHP. But being a neophyte in that area, I have no idea how to mark the sections of code I want to be restricted in a way that the script will recognize them, and maybe doing so is more trouble than it's worth. So anyone who does know PHP would really tickle my fancy if they could show me another way to do this.

P.S. I don't really have a co-worker named Angela. =)

Update 11.08.03: I have modified the code for the begin_restricted module above to make it a little less redundant (I was repeating some variables and code unnecessarily).


Comments: 7

That is great! I haven't bothered to install the restricted entry hack yet.. I like this version as well. Might be good for when I'm discussing Christmas gifts I'm working on, to keep my father in law from sneeking peeks *laughs*

by meowy at 08:37 PM on 10.26.03

I already did this on my site with PHP quite some time ago. It works best with the macros plugin installed. If you are interested you can mail me and I will show you the code.

by jade at 04:01 AM on 11.29.03

Quote: Perhaps for larger blocks of text, I'll create some alternate modules with these options; or explain elsewhere on my site about the restricted access feature..
Question: I am interested. Did you explain it somwhere? Or plan to do so? Thanks & keep on coding.

by kodiak at 08:26 AM on 12.09.03

Well, I meant an explanation to readers about why they might miss big chunks of entry content. I explain on my disclaimer page about the restricted access, and left it at that.

I did create some additional modules that would enable me to hide entire sections - I use little graphic dividers in the entries when I talk about multiple subjects. The modules hide the dividers as well, so no one will know there's a larger gap in the entry. That's pretty much the extent of it.

by girlie at 06:47 PM on 12.09.03

Hey there -- love the idea of being able to hide certain blocks of text, great work! So I want to try it out, but I'm a bit confused .. I installed the process tags plugin, but the scriptygoddess thing confuddled me. Do I replace her code with yours or do I use both?

Thanks :)

by Gry at 05:04 PM on 12.20.03

You would need to implement the Scriptygoddess code first on your site as instructed in that tutorial.

My code is an addition to the SG code, not a replacement.

by girlie at 06:20 PM on 12.20.03

Ah, ok - thank you :) Then I have to get my hands a little dirty with the scriptygoddess tutorial - I'm sure I'll conquer it sooner or later! :D

And once again, this idea is VERY interesting hehe.

by Gry at 07:39 PM on 12.21.03
Comments are closed on this entry
More Entries

Copyright © Virtual Venus