GetSimple Support Forum

Full Version: Use PHP in a component
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Still playing around with GetSimple and loving it. I would like to knew if there is a way to make this work.

call get_navigation(return_page_slug()) from a component ? When I attempt this it returns a error ?

example :

make a component named footer paste this in
Code:
<?php get_navigation(return_page_slug());?>


Thanks for any help.
PMB Wrote:Still playing around with GetSimple and loving it. I would like to knew if there is a way to make this work.

call get_navigation(return_page_slug()) from a component ? When I attempt this it returns a error ?

example :

make a component named footer paste this in
Code:
<?php get_navigation(return_page_slug());?>


Thanks for any help.

Which error? This should work (although you should put <ul>...</ul> around it to get valid HTML).
Include the component in the template using
Code:
<?php get_component('footer'); ?>
I was playing around some more. It is a sever security error. It will work on my localhost. But when I went live is when everything went bad.

Quote:Error 501: The server cannot complete the request because it encounters an error

Header values specify a configuration that is not implemented.

ModSecurity, web application firewall, possible secure attack prevention.

I have a work around working. But because i'm new to GetSimple, I'm just trying to learn best practices and what I can and can't do.

Thanks for the quick reply.
please give us the info from the server health check .. you can find that in the settings / first steps

this menu navigation should never be a security risk ... I see the same danger as eating ice cream ... it is harmless ;=)

are you on a windows-server?

another question: a navigation belongs into the template, why you put it into a component?
Hello again Connie.

health check is 100%. The above was just an example. Anywhere I try to include php (without hard coding it ). I get the above error. I'm on a linux server.

One nice reason I found to put the navigation in a component would be for a 3 col. footer. But yes I do understand your point about the template. I'm just try to test what I can and can't do.
PMB Wrote:I'm just try to test what I can and can't do.

that's a good approach ;=)
if you try to put PHP into a component, can you put any quoted strings there? For simplest example echo("text");? Since get_component() relies on both eval() and stripslashes() it will output unquoted string. Double backslashes to overcome it?
Ampersand Wrote:if you try to put PHP into a component, can you put any quoted strings there? For simplest example echo("text");? Since get_component() relies on both eval() and stripslashes() it will output unquoted string. Double backslashes to overcome it?

??? get_component works perfectly with single and double quoted strings, e.g. a component with
Code:
<?php echo "double".' single'; ?>
yes echo works, so it must have to do with something different than escaping quotes. When I put a filename into a component,
Quote:component content
require_once("filename.php");
template content:
<?php get_component('componentname'); ?>
it stops page rendering.

However this way:
Quote:template content:
<?php require_once("filename.php"); ?>
it works fine, even with further call of filename functions in the template.