On Mon, Oct 4, 2010 at 1:11 PM, LarryTX <[email protected]> wrote:
> I'm attempting to add a script to an index.ctp in CakePHP 1.3. I've
> added 'inline' => false to the $html->script statement. The problem is
> that the script gets added to $scripts_for_layout at the TOP. In
> default.ctp, there is another script that must be BEFORE the one added
> in index.ctp. (The order is important.) Is there anyway that I can get
> the script added to the bottom of the $scripts_for_layout in this
> case? Even better, is there any way to control the order of the
> scripts in $scripts_for_layout?
So move "echo $scripts_for_layout" below where you're loading your
other scripts in the layout. eg.
// files for every page ...
echo $javascript->link('lib/jquery-1.4.1.min');
...
// files loaded from specific views
echo $scripts_for_layout;
> If you're interested, I'm using the wonderful UI.layout plugin, and in
> some cases, I need the east (right) pane closed depending on the page.
> I have to initialize the plugin in default.ctp. Then, I have to add
> the specific directive to close the pane when I open that page, in
> this case index.ctp. If I try to close the pane before initializing
> the plugin, of course it won't work.
>
> I need to initialize the plugin in default.ctp because it's needed on
> all pages. I only need to selectively close the east pane on a few
> pages.
You should initialise the plugin in a separate file, global.js, or
whatever, that's loaded on every page. Put the code inside of jquery's
document.load procedure:
$(function()
{
// ...
});
What you can do is set a class on the body element of those pages that
should be handled differently. Or, because your body element is
probably in the layout, not the separate views, you could echo a line
of javascript that sets a variable, then test for that var in your
init code.
Check out the new CakePHP Questions site http://cakeqs.org and help others with
their CakePHP related questions.
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en