We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Hide plugin

Development and Programming

Cocoaholic's avatar
Cocoaholic
445 posts
19 years ago
Cocoaholic's avatar Cocoaholic

I really needed to add some comments to my template code today and couldn’t find a way to do this yet so I ‘wrote’ a plugin. You can use this plugin to hide code snippets or to add textual comments to your templates. Please let me know if something like this already exists or if you guys (Rick, Paul) will be adding something similar to EE soon.

If anyone finds it useful I might submit it, but for now you can download it here.

       
mascha's avatar
mascha
1 posts
19 years ago
mascha's avatar mascha

Why don’t you use this nifty

“<!– this is a comment –>”

stuff?

M.

       
Cocoaholic's avatar
Cocoaholic
445 posts
19 years ago
Cocoaholic's avatar Cocoaholic

Because I don’t want my comments to end up in the source of my website 😉

       
PXLated's avatar
PXLated
1,800 posts
19 years ago
PXLated's avatar PXLated

Hiding comments could be very useful…don’t have time to try it right now but will at some point 😊

       
Cocoaholic's avatar
Cocoaholic
445 posts
19 years ago
Cocoaholic's avatar Cocoaholic

It’s also nice to be able to temporarely hide a piece of code.

{exp:hide}
<h2 class="sidetitle">Categories</h2>

{exp:weblog:categories weblog="{master_weblog_name}" style="nested"}
<a href="http://{path=/index}">{category_name}</a>
{/exp:weblog:categories}

{/exp:hide}
       
EE lover's avatar
EE lover
50 posts
19 years ago
EE lover's avatar EE lover
If anyone finds it useful I might submit it.

It

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
19 years ago
Lisa Wess's avatar Lisa Wess

If you have ee tags inside of that, does that stop them from being parsed as well as hiding them? Or just hide them?

       
Cocoaholic's avatar
Cocoaholic
445 posts
19 years ago
Cocoaholic's avatar Cocoaholic

Maybe Rick or Paul should answer that one. If I’m not mistaken EE tags are parsed inside out, so in the example above the categories will be parsed first and then hidden (thrown away).

That’s all the plugin does at the moment, return nothing.

       
Ingmar Greil's avatar
Ingmar Greil
29,243 posts
19 years ago
Ingmar Greil's avatar Ingmar Greil
I really needed to add some comments to my template code today and couldn’t find a way to do this yet so I ‘wrote’ a plugin.

Does your template use PHP? I occasionally use

<? php // Comment line one // two // and three ? >
       
jrstueve's avatar
jrstueve
3 posts
19 years ago
jrstueve's avatar jrstueve

I like the idea… being able to hide stuff while working on the code, or extracting parts of troublesome code.

IIRC there was a thread somewhere that discussed being able to reverse the order of parsing, then it would also reduce the server time.

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
19 years ago
Lisa Wess's avatar Lisa Wess

Yea, you add parse=”inward”, if you search on parse in the user guide, it’ll come up. I”m not sure if magic doohickeys have to be done within the plugin to make it work, though.

       
Cocoaholic's avatar
Cocoaholic
445 posts
19 years ago
Cocoaholic's avatar Cocoaholic

I just uploaded a new version and downgraded it to 0.2 because it needs some more work. Added a ‘style’ parameter to specify what comment style you want to use.

{exp:hide} This is the default style (none) which will just hide the entire code or text and nothing will show up in the source of your browser

{exp:hide style="html"} <!– for HTML style comments –>

{exp:hide style="css"} /* CSS comments */ (using the values “php” or “js” will return the same style for PHP or JavaScript comments)

There are still some things to work out, one of them is nesting. For example, this won’t work:

{exp:hide style="html"}
{exp:hide}
code or text you want processed 
{/exp:hide}
{/exp:hide}

I will be away untill after the weekend, enjoy!

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
19 years ago
Jamie Poitra's avatar Jamie Poitra

Cool idea.

I’ve been doing a lot of plugin stuff myself recently and I’m pretty sure you are correct about the parsing. Plugins seem to be the last thing to go through the engine. So if an EE tag is in there it will get parsed and then the plugin will hide it afterwards so you can’t use your plugin for a performance gain of any kind.

But I like the idea of having comments hidden from users while still being able to view them in your templates. It would also be interesting to add the ability to have it not hide them in the source when a person logged in as a certain member group is viewing the page. So admins could still open the source and see comments but normal users would not.

Jamie

       
Jamie Poitra's avatar
Jamie Poitra
409 posts
19 years ago
Jamie Poitra's avatar Jamie Poitra

Of course it just occurred to me a simple conditional could do the user group thing too. But it would be nice to cut down on tags by having the plugin handle that.

       
Jake Lyman's avatar
Jake Lyman
20 posts
17 years ago
Jake Lyman's avatar Jake Lyman

Does anyone know if this plugin is still available? I’d like to “hide” some of my EE code for testing purposes. Thanks!

       
1 2

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.