+ Reply to Thread
Results 1 to 6 of 6

Thread: FCKEditor help

  1. #1
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    FCKEditor help

    I want to add like when they write [ PHP]text[ /PHP], it should become <source lang="php">text</source>

    How would I do that?
    Last edited by galaxyAbstractor; 11-09-2008 at 09:48 AM.

  2. #2
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: FCKEditor help

    I personally have never used and don't know FCKeditor, but if you have the string as a variable in PHP (for example, by submitting a form with the POST method), then the following will do just that:
    PHP Code:
    <?php
    $string 
    'my new array: [php]<?php $my_array = array(); ?>[/ php]';

    $string preg_replace("/\[php\](.+?)\[\/php\]/","<source lang=\"php\">$1</source>",$string);

    echo 
    $string;
    ?>
    will output:
    Code:
    my new array: <source lang="php"><?php $my_array = array(); ?></source>
    (space in example [/php] to prevent ending my own [php]block)
    Last edited by Scoochi2; 11-09-2008 at 10:35 AM. Reason: [php] tag problem :(
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  3. #3
    galaxyAbstractor's Avatar
    galaxyAbstractor is offline Community Advocate galaxyAbstractor is on a distinguished road
    Join Date
    Oct 2007
    Location
    Land of Null and Insanity
    Posts
    5,495

    Re: FCKEditor help

    Quote Originally Posted by Scoochi2 View Post
    I personally have never used and don't know FCKeditor, but if you have the string as a variable in PHP (for example, by submitting a form with the POST method), then the following will do just that:
    PHP Code:
    <?php
    $string 
    'my new array: [php]<?php $my_array = array(); ?>[/ php]';

    $string preg_replace("/\[php\](.+?)\[\/php\]/","<source lang=\"php\">$1</source>",$string);

    echo 
    $string;
    ?>
    will output:
    Code:
    my new array: <source lang="php"><?php $my_array = array(); ?></source>
    (space in example [/php] to prevent ending my own [php]block)

    nope does not work

  4. #4
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: FCKEditor help

    In that case, here's a few results from a quick Google search:
    Understanding FCKe plugings
    A possible similar plugin
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

  5. #5
    dickey's Avatar
    dickey is offline x10 Sophmore dickey is an unknown quantity at this point
    Join Date
    Sep 2008
    Location
    Singapore
    Posts
    128

    Re: FCKEditor help

    What scoochi2 posted should've worked, basically what you want is to use a string parser and string replace functions. so it should have worked.
    Don't get me wrong as I believe if and when I help someone I also help myself whereby whatever someone learns I also learn.

    But I will also accept credits or reps if you really want to part with it.

  6. #6
    Scoochi2's Avatar
    Scoochi2 is offline x10 Sophmore Scoochi2 is an unknown quantity at this point
    Join Date
    Aug 2008
    Location
    Southport!
    Posts
    185

    Re: FCKEditor help

    Quote Originally Posted by dickey View Post
    What scoochi2 posted should've worked, basically what you want is to use a string parser and string replace functions. so it should have worked.
    Indeed it does. The first thing I did was copy my entire code as is into a blank page.php
    Next, I got rid of that space in the closing tag that I mentioned. Then I turned on PHP and ran it in my browser.
    The following is what I saw:
    my new array:
    That's exactly what I expected to see. Doesn't mean it's right though ;)
    Next, I viewed the source of the page (because I know that the HTML <source> shouldn't give me any visible results, but as it is HTML, it will appear in the page source. The following is the source of my page:
    my new array: <source lang="php"><?php $my_array = array(); ?></source>
    So yes, it does work


    Vigge, can you confirm the results? IE, did you view the page in your browser and think it's not showing the string? Can you check the source and see if it's in there at all?
    Last edited by Scoochi2; 11-11-2008 at 06:30 PM. Reason: w00h00, this post made me a 'Sophmore' :D
    If anyone can see it, my post was meant for anyone who reads it. Don't take it personally or think I'm being condescending... :nuts:

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers