[Solved] [Documentation] Need help writing an application
Hi all,
I'm trying to write an Application. I'm using http://vanillaforums.org/docs/appquickstart as my guide.
I copy/pasted the applications/skeleton/ directory and changed everywhere the word 'skeleton' existed in that directory to my application name (agvanilla), paying attention to case.
I also changed an erroneous line at the top of class.skeletoncontroller.php from:
$this->Uses = array('Form');
to:
public $Uses = array('Database', 'DiscussionModel', 'Form');
...to mimic the a similar line at the top of the /applications/vanilla/class.discussionscontroller.php file
When I navigate to http://< ip >/agvanilla/homepage/index.php, I get:
[begin]
Page Not Found
The page you were looking for could not be found.
[end]
If I add var_dump calls to trace the code in class.agvanillacontroller.php, the code in its __construct() and Initialize() function is clearly being executed through to the end of each function.
Help?
Best Answers
-
I finally figured out what was going on. Here's how the file structure needs to be:
After copying the skeleton application and renaming all references to 'skeleton' to whatever the new controller will be known as ('agvanilla' in this situation) -- paying attention to case -- to be able to go to any of the following eqiuvalent URLs:
http://<ip>/agvanilla/
http://<ip>/agvanilla/index
http://<ip>/agvanilla/index/
http://<ip>/agvanilla/index.php
one must create an index method in the class.agvanillacontroller.php:
public function index() { $this->Render(); }
and then create the following file:
applications/agvanilla/views/agvanilla/index.php
Fill that index.php with whatever HTML you'd like.
Now navigate to one of those URLs above. Voila, it works!
0 -
peregrine MVP
you're the man.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
1 -
hbf MVP
Nice simple article on creating an application. Very cool. I may have to try my hand at that. Thanks.
1
Answers
I've never written a new application for Vanilla, so I can only help you think in the right direction.
Maybe, just maybe the problem has to do with routing, but I'm not sure. Let's focus on another thing first.
Before you get the, let's call it 404 error, do you see in which code block the 404 error is generated? You said you did a var_dump(backtrace), can you post that backtrace or will it reveal too much of the code you do not want to reveal?
Did you doublecheck the .htaccess file to reflect your IP address instead of the hostname?
There was an error rendering this rich post.
Results of debug_print_backtrace() in the :
No code executes in the agvanilla/controllers/homepage.php file, nor in the agvanilla/views/homepage/index.php file
>
I'm using the default .htaccess file:
Before you wrote your application and modified various programs, what was the exact url that took you to the discussions page and did it work?
The reason I ask, when i added an application, i just added it to the menu options
it may not be the correct way but this is what I did
I wrote a plugin and put this inside it.
on second thought mine just read some rss feeds and didn't really interact with the vanilla database per se other than to get some feeds, so it might not work for you.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
If I just go to:
http://<ip>/
It takes me to the discussions front page.
Can you do exactly the same, but then for the 404 error page, please :-)
There was an error rendering this rich post.
Ok:
That's at the line just before:
in class.dispatcher.php (line 329)
Aah, we're getting somewhere. This is for later moment to look at:
So what I usually do is figure out why that top statement isn't 'active' and therefore the code generates a 404 error. It means looking at the $PluginManagerHasReplacementMethod variable, the _ControllerMethod variable, etc, etc
If you have time, look at those variables using your var_dump method (which is great). I'll look at it also at my next opportunity
There was an error rendering this rich post.
Yep, that's where I'm digging right now
I finally figured out what was going on. Here's how the file structure needs to be:
After copying the skeleton application and renaming all references to 'skeleton' to whatever the new controller will be known as ('agvanilla' in this situation) -- paying attention to case -- to be able to go to any of the following eqiuvalent URLs:
http://<ip>/agvanilla/
http://<ip>/agvanilla/index
http://<ip>/agvanilla/index/
http://<ip>/agvanilla/index.php
one must create an index method in the class.agvanillacontroller.php:
and then create the following file:
applications/agvanilla/views/agvanilla/index.php
Fill that index.php with whatever HTML you'd like.
Now navigate to one of those URLs above. Voila, it works!
thanks nice overview
so you created
applications/agvanilla
Sounds like you know what you are doing it would be great if you put an annotated version in the vanillawiki, if it is not too proprietary or just put in some stubs for the application code. It would probably be very helpful.
http://vanillawiki.homebrewforums.net/index.php/Main_Page/
@philAG
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Done: http://vanillawiki.homebrewforums.net/index.php/Hello_World_Application
you're the man.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
Nice simple article on creating an application. Very cool. I may have to try my hand at that. Thanks.
Vanilla Wiki, Tastes Great! 31,000 viewers can't be wrong. || Plugin Development Explained
Thanks for the article. I have a question:
Does that mean that the skeleton application lacks a method in the controller called index() ? Wow, so the skeleton application wasn't complete!
There was an error rendering this rich post.
Yep basic idea of model controller view is every view has an associated controller method.
By that I don't mean helper views, which are included by other views.
grep is your friend.
Not only is the skeleton application not complete, it has a bug in the code which causes PHP to throw an error. You have to either comment out this erroneous line at the top of class.skeletoncontroller.php :
$this->Uses = array('Form');
Or you have to change it; I used this line from the main Vanilla application controller:
public $Uses = array('Database', 'DiscussionModel', 'Form');
@hbf -- watch out for that...
As I answered my own question, how should I proceed with all of the other posts in this topic? Am I doing the correct thing in liking, but rejecting each of them?
I would only reject if it was explicitly unhelpful.
grep is your friend.
I thought you had to choose either reject or accept. And choose reject if the message doesn't answer the question. Confusion here. I think if you answer your own question the moderator will mark it as solved.
my concept is you click like if it seems like the person put some effort into making a response and it kinda helped you on your way.
I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.
I wouldn't reject an answer until, like x00 says it's explicitly unhelpful. It keeps popping up that annoying message that I should accept or reject an answer, but I take that for granted.
The like is exactly like peregrine says, if it seems like the user made an effort, click the like button.
Here's a (small) thread about the 'like etiquette' : http://vanillaforums.org/discussion/19424/like-etiquette we could put our thoughts in there...
I'll accept your answer for you, if you like, send me a PM or tell me here in the thread please :-)
There was an error rendering this rich post.