Posts: 35
Threads: 6
Joined: Mar 2012
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
Posts: 6,266
Threads: 181
Joined: Sep 2011
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));
Posts: 35
Threads: 6
Joined: Mar 2012
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
[/i]
Posts: 6,266
Threads: 181
Joined: Sep 2011
actually that wont work sorry, raw text just gets output, hmm, i might be able to do it with output buffering
Posts: 6,266
Threads: 181
Joined: Sep 2011
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.
Posts: 3,491
Threads: 106
Joined: Mar 2010
It would be nice to have a return_component function in GS. Could be useful for this and other uses...
Posts: 6,266
Threads: 181
Joined: Sep 2011
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.
Posts: 3,491
Threads: 106
Joined: Mar 2010
2013-08-06, 01:05:40
(This post was last modified: 2013-08-06, 01:06:02 by Carlos.)
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.)
Posts: 6,266
Threads: 181
Joined: Sep 2011
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.
Posts: 35
Threads: 6
Joined: Mar 2012
(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....