Hi,
In some cases I do not want to echo, but need to return the content of:
get_page_content();
get_component();
======================================
The following does not work:
get_page_content(false);
return_page_content();
get_component(false);
return_component();
======================================
Does anyone know a way to make return work for this ?
hmm there is none for content... odd
I know there is a way to get content , and im sure this has come up many times...
lol maybe not, I am stumped
3.4 there is returnPageContent()
you could use ob buffer with get_page_content in 3.x, if not i18n surely has something
Hi,
Thanks for stepping in,
sorry I forgot to mention that I am building with the 3.3.16
What I could find is returnPageContent('slug');
This works fine for 1 language
The i18n plugin has return_i18n_component('slug') but it returns the output unprocessed
(includes the php tags, quotes and semicolon)
=======================================================
Yes the best working solution seems to make use of PHP output buffering
It works also nice with multi-language and it even allows
chaining api calls:
Working example on a template file:
PHP Code:
<?php
ob_start();
get_page_content();
get_i18n_component('test');
$maincontent .= ob_get_clean();
?>
On the front:
Code:
<div class="">
<?php echo $maincontent ; ?>
</div>
Works flawlessly ...
===========================================================
It is said that you have to be careful with ob memory usage
So I checked with memory_get_usage()
PHP Code:
echo memory_get_usage() . "<br>";
ob_start();
get_page_content();
get_i18n_component('test');
$maincontent .= ob_get_clean();
echo memory_get_usage() . "<br>");
unset($maincontent);
echo memory_get_usage() . "<br>";
There is no memory usage problem at allĀ
F.