« Luck in King-size chunks Payback time! »

Removing content without deleting

:: Tuesday, Apr 4th 2006 @ 17:58 :: Web design & Coding ::

HTML comments show up in the source, so what if you want to remove text from the page without actually deleting it from the files?

<?php if (false) {?>
  (content to be removed…)
<?php } ?>

6 Comments

RSS feed for comments on this post.

  • 1

    :oops: I have absolutely no idea what that means.

    Comment by jafer — Apr 7 @ 2:55

  • 2

    Well for example, I used to have an introduction box at the top of the main page. When I started pulling the dog’s blog feed there I removed the introduction by commenting it out. However, it showed up in the source code. By replacing the HTML comment tags <!- - and - - > (without spaces) with the code above, I was able to keep the text I had written (in index.php template) but it doesn’t show on the outside.

    The if “function” needs an expression that is calculated as true, so by writing ‘false’ directly I ensure that the expression is always false, thus the stuff between curly brackets is completely ignored.

    Comment by Minna — Apr 7 @ 17:50

  • 3

    ooh, would that work with source codes too? *was wondering :roll: (so people can’t really view SOME parts of your source code?)

    Comment by Vera — Apr 9 @ 1:57

  • 4

    You want something on the website but don’t want it seen in the source code? That sounds tricky. Some people have disabled the viewing of their sourcecode altogether, but I can’t think of a way to hide a part of it…

    Comment by Minna — Apr 9 @ 10:42

  • 5

    Hiding the source is a little tricky. By nature, the Internet is open and free, so there’s no built-in function. You can disable context-clicking for images and source, but that will probably only keep casual surfers from access. It still goes to the cache.

    You might be able to use PHP or ASP or something server-side to grab the source and display to the browser.

    Comment by Kory — Apr 9 @ 23:35

  • 6

    Yeah, it seems that nothing can hide it. But that’s okay though .. was interested to know if anyone knew anything about that :wink:.

    Comment by Vera — Apr 11 @ 4:18

Sorry, the comment form is closed at this time. You can leave a comment here