SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    strip_tag, but put them back!

    Hi all
    I'm sure my question is not new to anybody who has tried to build a content management interface...

    How do you strip the tags off an html page, to get only the text content, but then, after this text content has been updated and re-written, put it back where it belongs, i.e. between the tags it came from!

    The strip_tag() function seems to do a pretty good job for the first step, but as far as I know it doesn't store anywhere the stripped tags (so there's no way of putting them back).

    Anybody has found a solution to this?

  2. #2
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seb, can you explain why you need to both or the reason. I do not follow why you would want to insert tags again.
    Maybe you could cache a copy of the unedited page and run the strip_tag() on an expendible copy of the page....
    Troy

  3. #3
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    well, if I want to give my clients the ability to edit all the text content on their pages, via a browser interface.
    I need first to get all that text out of the html, in a textarea.
    So they can change the text.
    Then I need to put the text back in the page, but at its place, between the html tags, so all the layout, font color, css styles etc is preserved.

    Say if there was, in the original code:

    <p class="style1">here is some text</p>
    I want to give
    "here is some text"
    I to my client to edit, then I want to write the new text in the page, between the
    <p class="style1"> and the </p> tags.

  4. #4
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seb, ok, that makes much more sense. One more question. Will the content be an updated chunk of text or just added continuously?
    Troy

  5. #5
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seb, I think the easiest way to do this is to just manage the text in a database. If you ahave a specific reason that you need your clients to have the ability to insert via text files, please let us know so we can help out. I think I have a chunk of code that could help.
    Troy

  6. #6
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks for your following this question.

    Here's what I'm really trying to do:
    Enable the client to update any chunk of text in their web site, regardless of how the website has been built and designed in the first place.

    So that means no database, and nothing in the pages already there to help.
    My idea of the interface would be:
    1. enter the url of the page you want to update
    2. enter the first words and the last words of the chunk of text you want to update
    3. A regex finds the chunk of text, strip the tags, and echos it in a textarea.
    (I figured it all out up to here.)
    4. The problem is in the next step: Put the new text back in the page.

    I was thinking of cutting the text in as many text areas as necessary, so as to echo only chunks that are in between htmltags, and writting comments in the file around each chunk of text with a random name, for example:

    original file:
    <p class="style1">here is some text</p>
    write in the file:
    <p class="style1"><!-- chunk1 start-->here is some text<!-- chunk1 end--></p>
    Then echo in the textfield
    here is some text
    as $chunk1
    Then to put back the new $chunk1text after editing, I'd look for
    "/<!-- chunk1 start-->.*<!-- chunk1 end-->/"
    and write it in there...
    Do you have a better idea? Or some script ready?
    Thanks

  7. #7
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think what you are asking for is a basic CMS with add/edit/delete features. The only thing I have implemented so far is using phpBB as a CMS. It's pretty user friendly seeing as it's a basic forum and you can control the users access to any category/forum. How the content looks on the website is up to the designer. But that involves a database and it doesn't seem to be what you want. Sorry
    Troy

  8. #8
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know what a CMS is.

  9. #9
    SitePoint Addict Knightime's Avatar
    Join Date
    Jan 2003
    Location
    USA
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Seb, a CMS is a Content Management System. The basic feature of a CMS allows a user to add/edit/delete "content" (anything from text to whatever) to a webpage(s) using a simple graphical User Interface (GUI) without having to go into the page itself and edit code. In general, the content is saved to some sort of database and the code displays te content however the designer wants. With a CMS, anyone who is smart enough to post to a forum can put content on a website.
    Troy

  10. #10
    SitePoint Addict
    Join Date
    Jan 2005
    Location
    nyc
    Posts
    223
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hey thanks -I figured what CMS could stand for aftre a while.

    well yes that's what I'm building, a CMS, but the diffference is that the one I'm building is meant to be usable on any already built website, even (and specially) if the site was not built with server-side functionality or databases or anything like that.

    I'm trying to build a CMS where all you'll have to do is type the URL of the page you want to update, then search for the chunk of text you want to edit, et voila.

    My CMS should work anywhere, the only condition being that the file permission of the page you want to edit is set to writable (666).

    So it's a different concept than the CMS you're talking about. My CMS would be for people who know nothing about web technology and already have a static web site that only their webmaster can update. With my CMS, provided that they figure out how to set the appropriate file permissions, they wouldn't need a web master anymore, and they could update their site without having to re-build its information architecture or implement any server-side technology.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •