GetSimple Support Forum

Full Version: Rich text editor in components
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,

I was trying to find some plugin that will be able to replace the endlines with <br> in theme components - so there would not be neccesary to use HTML tags when editing components...

Is there some solution for this? Or maybe something that will use rich text editor in components? Anything usefull would be nice Smile
How are you running the component ?

There is the php function nl2br(); You could wrap your text in it.

PHP Code:
<?php

$text 
"faskldfjasdkfaskdfasdfsdf
asdfklsjdfasdf
sdf
as
df
asdfasdfasdf
"
;

echo 
nl2br($text);
?>

or for the component

PHP Code:
echo nl2br(get_component(blah)); 
I'm using
PHP Code:
<?php get_component('component-name'); ?>

I've tried the to use that funkction - but since I'm more designer didn't get the BR's - just single line Sad[/i]
actually that wont work sorry, raw text just gets output, hmm, i might be able to do it with output buffering
PHP Code:
<?php
    ob_start
();
    
get_component('tagline');
    echo 
nl2br(ob_get_clean());
?>

That should work inside a theme file for a text only component
rich text components are coming in next major version.
It would be nice to have a return_component function in GS. Could be useful for this and other uses...
Yeah but we have to eval components since they contain php blocks, That is why we have to add "snippets" for non code templates.

Not sure there is a way to eval and not output non-code blocks, aside from wrapping components in output buffering.

We might be able to use http://www.php.net/manual/en/function.cr...nction.php instead of eval for components. I have never used it, it might have some advantage but I am not sure it would solve this problem.
I mean a function that just returns the component as a string, unprocessed. Just like I18N's return_i18n_component.

Components can be used for other things, not only php scripts. Or you can have some component to be processed by a plugin, not just by get_component. (In fact some of mvleck's plugins do it -for custom rendering-, but I suppose they the above mentioned function to get the component content.)
I think that creates inconsistencies. If you want the raw then you can always grab it manually from the array or xml.

Maybe if there was an additional parameter instead to $processphp(false), for get and return. Or get_components_text or similar?

I still prefer the idea of a seperate "component" type for static content.
(2013-08-06, 00:37:03)shawn_a Wrote: [ -> ]
PHP Code:
<?php
    ob_start
();
    
get_component('tagline');
    echo 
nl2br(ob_get_clean());
?>

That should work inside a theme file for a text only component
rich text components are coming in next major version.

thank, it works....