I must have something setup wrongly as I can't seem to get the sample code working!
Using the example straight from the docs but put into a module called test I don't appear to be able to display the data passed into a view?
I have a module called test that contains a controller called Test.php and two views, called test.php and greeting.php
The controller code in Test.php is as basic as it can get:
Nice to see you!
This is the json information:
The output from test is as you would expect:
Hello
Nice to see you!
but the output from greeting is not as you would expect:
Hello
Notice: Undefined variable: name in C:\inetpub\wwwroot\watercolour\modules\test\views\greeting.php on line 1
Nice to see you!
This is the json information:
{
"name": "David Connelly"
}
Anyone know what might cause this to happen on such a simple test?
Not able to get data passed into a view using example code
3 years ago
3 years ago
#1
3 years ago
#2
Hello,
Can you post your controller code calling your viewfile.
Be sure to use code tags around your code
Square brackets with "code" inside for the beginning tag and
Square brackets with "/code" inside for the ending tag. Omit the quotes.
Dan
Can you post your controller code calling your viewfile.
Be sure to use code tags around your code
Square brackets with "code" inside for the beginning tag and
Square brackets with "/code" inside for the ending tag. Omit the quotes.
Dan
3 years ago
#3
Sorry here is the post code with the correct tags round it to make it display properly:
Test Controller:
This is test.php view code:
This is the greeting view code:
This is the output from the test.php view as you expect:
This is the output from the greeting.php view file:
As I said in my first post this is so basic and taken pretty much from the docs explaining views.
Further to my last post I did try altering the controller code to call the view through a template and when I did this is worked?? But just calling a simple view refuses to present the data that is passed in as proved by the json(data) in the greetings view.
Test Controller:
This is test.php view code:
This is the greeting view code:
This is the output from the test.php view as you expect:
This is the output from the greeting.php view file:
As I said in my first post this is so basic and taken pretty much from the docs explaining views.
Further to my last post I did try altering the controller code to call the view through a template and when I did this is worked?? But just calling a simple view refuses to present the data that is passed in as proved by the json(data) in the greetings view.
3 years ago
#4
I have made some progress with looking into this.
Rather than just use the variable as it should have been available, i.e. $name, I found that if I referenced it as $data['name'] then it was displayed??
This is the html to do as described above:
As you can clearly see this is not working as expected?
Rather than just use the variable as it should have been available, i.e. $name, I found that if I referenced it as $data['name'] then it was displayed??
This is the html to do as described above:
As you can clearly see this is not working as expected?
3 years ago
#5
Hi Tony,
Seems a bug crept into the framework, which has now been fixed.
was missing from the load_view_file() method in Trongate.php
Please either create a new app with the Desktop app or load your existing app into your favourite text editor, then go to the 'engine' folder and change the version number in the 'licence.txt' to something lower than the following:
Open the desktop app and 'Modify Existing App' load your app and update the engine folder and it should all be working for you.
Cheers,
Si
Seems a bug crept into the framework, which has now been fixed.
was missing from the load_view_file() method in Trongate.php
Please either create a new app with the Desktop app or load your existing app into your favourite text editor, then go to the 'engine' folder and change the version number in the 'licence.txt' to something lower than the following:
Open the desktop app and 'Modify Existing App' load your app and update the engine folder and it should all be working for you.
Cheers,
Si