Dynamically add a stack using Jquery
Permalink
Hello again!
I have an autonav drop down navigation on my site that (beyond just the nav items) gets populated with HTML content via Jquery. The first screen shot should help convey what I mean.
What I need to do is call a stack instead of just insert HTML. What I have tried is making a simple PHP file called newsletterform.php in my theme directory which I .load() with Jquery.
newsletterform.php looks like this:
and I load it using this bit of Jquery:
The Jquery works and it loads the PHP file, but the C5 specific class 'Stack' isn't found and it gives me a fatal error where I was hoping to see the Newsletter Form stack... See the second screenshot
I assume either I have my newsletterform.php in the wrong location or I'm not including some essential elements in the PHP file itself.
Any help would be great!
I have an autonav drop down navigation on my site that (beyond just the nav items) gets populated with HTML content via Jquery. The first screen shot should help convey what I mean.
What I need to do is call a stack instead of just insert HTML. What I have tried is making a simple PHP file called newsletterform.php in my theme directory which I .load() with Jquery.
newsletterform.php looks like this:
<?php $stack = Stack::getByName('Newsletter Form'); $ax = Area::get($stack, STACKS_AREA_NAME); $ax->display($stack); ?>
and I load it using this bit of Jquery:
$('.subnav-item-4 #subnav-html').load('//newsletterform.php');
The Jquery works and it loads the PHP file, but the C5 specific class 'Stack' isn't found and it gives me a fatal error where I was hoping to see the Newsletter Form stack... See the second screenshot
I assume either I have my newsletterform.php in the wrong location or I'm not including some essential elements in the PHP file itself.
Any help would be great!
I found these after a quick Google search.
http://stackoverflow.com/questions/12524228/how-to-load-php-file-in...
http://forum.jquery.com/topic/load-php-file-into-a-div...
http://stackoverflow.com/questions/12524228/how-to-load-php-file-in...
http://forum.jquery.com/topic/load-php-file-into-a-div...
Yes, I saw that post when I was first trying it out. In my original post I use basically the same method of loading a .php file into a DIV using the Jquery .load() function.
The problem is within the PHP file I'm trying to directly call a stack using C5 classes which aren't available the way I've done it. The PHP code I used works when put into a page type but not in a separate file by itself. I don't know how to make the necessary C5 classes available =/
The problem is within the PHP file I'm trying to directly call a stack using C5 classes which aren't available the way I've done it. The PHP code I used works when put into a page type but not in a separate file by itself. I don't know how to make the necessary C5 classes available =/
The key to doing this is to go through the intermediary of a c5 tools file, which will load a basic c5 environment.
Could you elaborate a bit more or point me in the direction of some documentation that is relevant?
You could look at my Ajax Lessons howto and associated block for a package or block level tools file.
There are also some other ajax howtos.
There are also some other ajax howtos.
Unfortunately I don't know much javascript, not to mention ajax, which is what you'd need here.
From what I see, it would be much more complicated than you imagine.