I can not figure out how to call the function |
[eluser]seobot[/eluser]
HellO! Problem exists, there is the private function "delivery", which must have a value that comes into it. Code: class Catalog extends CI_Controller { It input parameter must be passed out of the array, which is obtained through the model database. In viewer this parameter is obtained from Code: <?php foreach ($catalog as $row): ?> Here it's the problem, can not figure out how to make that "delivery" in the viewer took the $num. Thank you!
[eluser]noslen1[/eluser]
I think you should create and use a Helper function instead of your Controller function : /helpers/myhelper_helper.php Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); /controllers/catalog.php Code: public function id($catId = NULL, $num = 0) {
[eluser]seobot[/eluser]
Thank you! But as we now bring in the viewer to the bulkhead viewer in "foreach" array did not take the last entry in the array controller parameter "delivery"? Code: xdebug_var_dump($catalog['delivery']); gives value to the controller Code: string '5%' (length=2) yes - this is the correct data. but in the viewer now insert with loop through the array $date['catalog']?
[eluser]noslen1[/eluser]
Your view should remain the same : Code: <?php foreach ($catalog as $row): ?> The "delivery" field displayed here has been changed into your controller, through the helper function, and will output "5%" or 'Free!" like in your var_dump()
[eluser]seobot[/eluser]
But in your case, the controller is "delivery" is written to the array $catalog and viewer displays the loop array of $data. That's what gives me var_dump in your example: Code: string '5' (length=1) From the controller just an array $catalog does not get in the viewer. that's the problem
[eluser]noslen1[/eluser]
In your controller you should have Code: foreach ($data['catalog'] as $catalog) { Meaning that $catalog is part of $data! $catalog is each element of the $data variable passing through the loop. So when next line you got Code: $catalog['delivery'] = delivery($catalog['delivery']); So in the foreach loop, when you change $catalog, $data changes too, and as it's passed to your view, it should display the right data. Gimme your code from Helper/Model/Controller/View please. I don't get it.
[eluser]seobot[/eluser]
please get me your email, forum not posting my message, аorum writes - I spammer))
[eluser]noslen1[/eluser]
Not sharing my email for you mate. Just wait until you can post again. And why could you post that last one ? ...
[eluser]seobot[/eluser]
Error Message Due to a heavy increase of spam within our community, the privilege of posting certain content is currently reserved for active community members and those who have purchased our software. If you feel you have received this in error, please contact [email protected] with a support key of bgp68s9y-grsogk0s-8kc8ggcs-k4w48w for more information.
[eluser]seobot[/eluser]
Hmmm I made a call to a helper in the "viewer" and it worked as it should. That is processing in the controller is not needed, since necessary data to be passed in a single cycle. View Code: $this->load->helper('catalog_helper'); |
Welcome Guest, Not a member yet? Register Sign In |