|more useful options|
Re: Populating an HTML Templateby injunjoel (Priest)
|on Mar 28, 2006 at 00:15 UTC||Need Help??|
Though there are many things that could be suggested about your code the most important is to adopt the use of strict and warnings.
Other than that I get the feeling you have not provided all of the relevant code in the example you give.
For instance where do %loop_data and $loop_data get initialized? What is suppose to happen to ($name,$value) in your
I think I follow what you are attempting up until you close your filehandles... Then things get murky.
Empirically @loop will never hold anything since you never fill it. Your #fill in the loop, foreach block creates and fills in $name and $value that fall out of scope with each iteration, @loop is never involved.
Now if I follow your intent, and this is a big stretch to say the least, here is my suggestion for what I think you are shooting for (However not having seen your HTML template its a guess at best).
Untested mind you.
Then continue with your template calls.
It would be helpful to see what the markup (HTML) looks like that you are filling with "loop" in your $template->param call.
without that everything is simply a shot in the dark.
Okay, thats definitely helpful.
So given the code.
I am lead to think you would like $name to appear in "part1" and $value to appear in "part2". Am I getting warmer?
Lets modify the loop I suggested earlier to accomplish this.
That should do it. I hope that helps.
And one more thing, have a look at the range operators for another way to handle your file partitioning.
"I do not feel obliged to believe that the same God who endowed us with sense, reason and intellect has intended us to forego their use." -Galileo