How to begin a foreach loop in one function and end it in another. Possible? |
[eluser]Gwarrior[/eluser]
Code: function create_loop($loop_post_name, $content, $order="desc") { Above is an example of what I speak of. It's pretty imperative that it functions this way, as I have designed an entire CMS thus far around this model. Yet when I run it, it generates the error: Quote:Fatal error: Cannot redeclare create_loop() (previously declared in C:\wamp\www\contentcreator\system\application\helpers\cc_helper.php:42) in C:\wamp\www\contentcreator\system\application\helpers\cc_helper.php on line 42 Here is my usage of it: Code: <?php create_loop('News Posts', 'article'); ?> So obviously I am doing something wrong. Problem is, I have no idea what that something may be. Any help would be great! *ps, the functions are being called from a helper and I am aware they would produce no content and an error if ran this way, but I can even get to that point, therefore I didn't include database calls and other things that would be looped.
[eluser]bigtony[/eluser]
Sounds like the helper is being included more than once. You could wrap your helper function within an existance check: Code: if (! function_exists('create_loop'))
[eluser]Colin Williams[/eluser]
First of all, please realize that your functions just return strings. Nothing is going to happen when you successfully run the functions. You would have to eval() the function result: eval(create_loop('News Posts', 'article); My suggestion is that you go back to the drawing board.
[eluser]Gwarrior[/eluser]
What other way would I have of deploying this? I know I've seen MANY CMS's do something very similar. Sometimes it's with a templating language like Wordpress and sometimes it's with functions, like Perch. If it's not possible, hey, I won't do it. But there has to be another workaround other than making users write: Code: <?php |
Welcome Guest, Not a member yet? Register Sign In |