Author Topic: Flatfile editinplace CMS (SOLVED)  (Read 582 times)

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Flatfile editinplace CMS (SOLVED)
« on: September 09, 2010, 02:18:12 PM »
I recently made a flatfile cms (+ edit in place).  Here's an example of how it shows the <br>'s when hitting enter. The password is demo.


Now when you click inside (in any text field - there are 4), when hitting enter it makes a new line without showing a <br> tag. Clicking outside and inside the textarea, it will show all the line breaks you've made.


My question is how to hide the <br> tag. What I've searched, found and tried the following:


Code: [Select]
$content=nl2br($content);
and
$content = str_replace("<br>", "\n", $content);


Neither worked.


Also when using this code


Code: [Select]
$file1 = include '/ccms/files/edit.txt';
echo $file1; // This outputs the file.


to show the content on another page, it adds a number 1 to every textarea I have on the original page. You can see the number 1 error here.
« Last Edit: September 14, 2010, 06:26:11 AM by wizr »

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 511
  • Karma: +4/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #1 on: September 09, 2010, 02:27:15 PM »
Hi there,

I'm assuming you've called htmlentities() - in this case you way want to use:

Code: [Select]
$content = str_replace("&lt;br&gt;","\n",$content);
Let me know how it goes.

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #2 on: September 09, 2010, 03:03:28 PM »
Thanks for the suggestion, but this still doesn't solve my problem. Even after entering that the <br>'s are still visible in the textarea.


Does this help you? If that's what you meant by the html thingy.


PHP Code: [Select]
$fieldname htmlspecialchars($_GET['fieldname']);

Any other suggestion?
« Last Edit: September 09, 2010, 03:31:30 PM by wizr »

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 511
  • Karma: +4/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #3 on: September 09, 2010, 03:54:25 PM »
Is $fieldname the data that's being outputted into the textarea? If not what is that variable? And it's origins?

Basically I'm assuming you have a setup like:
Code: [Select]
<?php
$area_contents 
htmlspecialchars($content);
?>

<textarea><?php echo $area_contents?></textarea>

Long story short, what is the breakdown of variables and PHP used to output into that textarea (if I know the origin of the string, it's much easier to work out where's best to manipulate, and how).

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #4 on: September 09, 2010, 04:14:50 PM »
What I'm using is:

PHP Code: [Select]
<?
$thefile 
"files/edit.txt"/*THIS IS THE FIRST TEXT FILE*/
$thefile2 "files/edit2.txt"/*THIS IS THE SECOND TEXT FILE*/
$thefile3 "files/edit3.txt"/*THIS IS THE THIRD TEXT FILE*/
$thefile4 "files/edit4.txt"/*THIS IS THE THIRD TEXT FILE*/


$textInfile file_get_contents($thefile);  /*THIS IS THE FIRST TEXT FILE*/
$textInfile2 file_get_contents($thefile2); /*THIS IS THE SECOND TEXT FILE*/
$textInfile3 file_get_contents($thefile3); /*THIS IS THE THIRD TEXT FILE*/
$textInfile4 file_get_contents($thefile4); /*THIS IS THE FOURTH TEXT FILE*/



<div id="change"><span id="a1" class="editText"><? echo $textInfile?></span><>
<br />
<div id="change"><span id="a2" class="editText"><? echo $textInfile2?></span><>
<br />
<div id="change"><span id="a3" class="editText"><? echo $textInfile3?></span><>
<br />
<div id="change"><span id="a4" class="editText"><? echo $textInfile4?></span><>
?>



Everything put into the textarea is getting saved to http://krneky.com/ccms/files/edit.txt (there are 4 files and 4 text areas).


In the text area is says <br>. But when you look at the file lets say http://krneky.com/ccms/files/edit3.txt you can see there's a <br />.


And this is kinda the setup:


PHP Code: [Select]
$fieldname htmlspecialchars($_GET['fieldname']); 
$content stripslashes(strip_tags($_GET['content'],"<p><img><i></i></p><h1></h1><h2></h2></a><li></li><a><strong><em><strike><b>"));
$content trim($content);
$content=nl2br($content);



I'm confused.
« Last Edit: September 09, 2010, 04:21:41 PM by wizr »

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 511
  • Karma: +4/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #5 on: September 10, 2010, 07:03:26 PM »
Hey, I tried your code:
Code: [Select]
$content = stripslashes(strip_tags($_GET['content'],"<p><img><i></i></p><h1></h1><h2></h2></a><li></li><a><strong><em><strike><b>"));
$content = trim($content);
$content = nl2br($content);

I got <br /> tags, but they went as soon as I commented out the nl2br() function. As for getting <br> instead of <br /> - I was unable to replicate this issue. See if removing nl2br fixes it, if not i would be tempted to suggest re-coding the outputting/fetching of the data (taking note of the output as you do certain things to it)

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #6 on: September 10, 2010, 07:45:21 PM »
I've tried this in different variations, maybe this info will help you?

How it all really works:
It makes a textarea that is writable to a .txt file. I display this text area with:
Code: [Select]
<div id="change"><span id="a1" class="editText"><? echo $textInfile; ?></span><>.
This goes trough:
PHP Code: [Select]
<?
$thefile 
"files/edit.txt";
$textInfile file_get_contents($thefile);
?>

This saves the file to edit.txt
User enters content into the text area and it writes it directly to the txt file once the user clicks out of the area.


So far the most efficient thing that worked (or not) is :
PHP Code: [Select]
str_replace("<br>""\n"$content); This would be perfect if it didn't disable <br>'s completely.


Also another thing, when you click on the text area on http://krneky.com/ccms (password demo) the text area shows normal <br> tags, while the ones saved in http://krneky.com/ccms/files/edit3.txt (the text files), shows <br />.

I have no idea what else is there to try.

I'm also using

- http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js
- http://krneky.com/ccms/js/editInplace.js
- http://krneky.com/ccms/js/wkrte.js
- http://krneky.com/ccms/js/jquery-1.3.2.min.js

Do you think any one of these may be causing problems?

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #7 on: September 11, 2010, 01:26:21 PM »
I also tried
PHP Code: [Select]
<?php  
  
echo "<pre>";
  echo 
$file1;
  echo 
"</pre>";
?>
but still no luck.
« Last Edit: September 11, 2010, 01:28:41 PM by wizr »

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Hiding br tags in textarea (flatfile editinplace cms)
« Reply #8 on: September 12, 2010, 12:40:44 PM »
Everyone, this cms is coming close to being published. Here we go: WonderCMS (password for the demo: admin)
« Last Edit: September 12, 2010, 05:10:06 PM by wizr »

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
(flatfile editinplace cms) Solved and ready for download!
« Reply #9 on: September 13, 2010, 02:51:09 PM »

The problem was fixed by changing


Code: [Select]
function editBox(actual) {
if(!changing){
width = widthEl(actual.id) + 20;
height =heightEl(actual.id) + 2;
actual.innerHTML = "<textarea…"
changing = true;
}
actual.firstChild.focus();
}


to


Code: [Select]
function editBox(actual) {
if(!changing){
width = widthEl(actual.id) + 20;
height =heightEl(actual.id) + 2;
str = actual.innerHTML;
actual.innerHTML = str.replace(/<br>/gi, "");
actual.innerHTML = "<textarea…"
changing = true;
}
actual.firstChild.focus();
}


The WonderCMS is now available for download: WonderCMS
« Last Edit: September 13, 2010, 02:53:42 PM by wizr »

Smokey PHP

  • Web Developer
  • Expert PHP Helper
  • Senior Member
  • *****
  • Posts: 511
  • Karma: +4/-0
    • View Profile
Re: Flatfile editinplace CMS (SOLVED)
« Reply #10 on: September 14, 2010, 02:57:55 PM »
Cool, glad you got it sorted!

Where's it available from?

wizr

  • New Member
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Flatfile editinplace CMS (SOLVED)
« Reply #11 on: September 15, 2010, 01:06:52 AM »
I am not supposed to link it, (administrator marks it at spam). What can I say, just google wondercms krneky, I hope you find it. :)


Cheers..