include prototype helper in cakeph2x - php

hi i am new in cakephp 2x.
i am working on the backend and i did some insert update and delete in it.
i also did the pagination in the cakephp with ajax. now i want to create the popup for the seatch functionality. i want to use the modalbox.js for that prototype.js and scriptaculas.js
but when i need this all the ajax is stopped working. i dont know why.
i read the just insert as helper so i write this code in the controller
public $helpers = array('Html', 'Form','Session','Ajax','Js'=> array('Prototype','Scriptaculous'));
now tell me what to do the next ?
i have included the helper but from where i can found this helper file ?
i just want to open the popup file
Thanks in advance

The ajax stop working, may be because of the compatibility factor of those js files. But you can't enter js files as helper files. Only helper files can be on helper folder under view folder.

Related

How to find out which view file is loaded in Joomla 3.2?

I'am templating the website under the Joomla 3.2.0 for HikaShop ecommerce component, and would like to find out which file is loaded with following code, so I could correctly override the styles for specific file.
The filename I'a working with is root\templates\MY_TEMPLATE\html\com_hikashop\user\registration.php. Inside that file there is a small part of code which underloads custom fields I would like to override with custom styles:
<div class="address-fields">
<?php
$this->type = 'address';
echo $this->loadTemplate();
?>
</div>
Anyone knows which filepath is exactly loaded with the following $this->loadTemplate(); ?
Not sure if you are using it the same way as it is used here, but they explain it as if the parameters you pass in the function loadTemplate(), actually as loadTemplate(address) would be files in your case found in registration_address.php
hey, It's worth a shot checking it out
SEE HERE

How to call a javascript function from .js file in a Drupal module file

I'm trying to modify an existing module to insert collapsible div.
my javascript functions are in the file 'my_module.js' and look like that :
my_module.js
function myFunction1(param){
...
}
function myFunction2(paramA, paramB){
...
}
I added my_module.js in module file using drupal_add_js and then I don’t know what to do next!
<?php
drupal_add_js(drupal_get_path('module', 'my_module') . '/my_module.js');
// -----> I want to call myFunction2 here !!
?>
The website has Drupal core 6.24.
thx
Just continue with my_module.js as normal javascript file. You can try to insert div by using JQuery.
$("#foo").append("<div id='my_collapsible'>hello world</div>")
And by JQuery attach to #my_collapsible some actions you want (make it collapsible).
That method should actually work.
Have you:
Checked the file paths are correct
Checked in firebug/webkit inspector that the JS file is being loaded?

CodeIgniter 1.7 reCaptcha Help

http://codeigniter.com/wiki/ReCAPTCHA/
Okay. So I download the code. Move all the files to the appropriate folders. Set the keys in the config/recaptcha.php file. Then where I have my form submit logic I put in the
$this->form_validation->run()
function.
Then in the HTML I do what?? I need to display the captcha for user input. I see google's code for adding the php recaptcha into non-code igniter documents, but I'm not sure which parts of that are relevant. And I'm not sure how I'm supposed to be making calls to particular files. Right now
<? $this->load->view('recaptcha.php');
$publickey = "thekeynumbersandgibberish";
echo get_html($publickey);
?>
this currently breaks my HTML page, I figure I'm not calling the file and function correctly using code igniter syntax. What is the proper syntax? This was not included in the code igniter documentation.
Insight would be appreciated.
You need to call this in your controller first
//In your Controller
$data['recaptcha'] = this->recaptcha->get_html();
$this->load->view('my_view',$data); //try it with the test page first
//In your View
$this->load->view('recaptcha.php');
The instructions in the wiki are pretty straightforward. Don't load the files in the view. Assign the HTML in the controller.
This is the normal process when working on MVC.
There's a basic CI tutorial here : http://net.tutsplus.com/tutorials/php/codeigniter-basics/

Javascript source in partial view of symfony

I'm using symfony 1.4, I wrote a piece of js code to use in a template, and I want to put it in a JS separated file because I'll use it many times in the code.
I added the JS to the template using:
<?php use_javascript('mi_js') ?>
This templates has some ajax calls that refresh zones of the view with renderPartial method. This new zones also use the JS code, so I need to add this code in the partial view.
But if add:
<?php use_javascript('mi_js') ?>
in the partial, then it doesn't work.
To get this work I have to put all the JS code in the partial, like:
<script type="text/javascript">/*<![CDATA[*/
$('.mi_class').click(function() {
var a = $(this).parent();
...
As I told I don't want to do this.
Any idea what can I do? Any template method to do this?
Thanks in advance.
Alejandro G.
The reason why you have to put the code in the partial is the following:
When you use use_javascript('mi_js') then the (path to the) JS file gets added to the sfResponse object. Then, when the templates get rendered, all the JS files get included into the layout file via get_javascripts().
But now as you only render the partial and send the results back via Ajax, the JS files get not included.
I suggest to put your code into a function and add it to the header of your HTML file. Then in the partials you call:
<script type="text/javascript">/*<![CDATA[*/
$('.mi_class').click(the_new_function())
(Maybe you have to define parameters, I don't know).
You can attach event handlers to future DOM elements via jQuery's live() method. Another way is to bind handlers directly after loading your partial.
How about adding the JS file in a normal way to the parent page that utilises the partial, instead of the partial itself.
If the partial is called in lots of places, I'd just add it to the application's or modules' view.yml file.

How to switch layout files in Zend Framework?

I'm sure it's a simple one-liner, but I can't seem to find it.
How can I use a different layout file for a particular action?
Update: This worked for me, thanks!
// Within controller
$this->_helper->_layout->setLayout('other-layout') //other-layout.phtml
//Within view script
<?php $this->layout()->setLayout('other-layout'); ?>
From inside a Controller:
$this->_helper->layout->setLayout('/path/to/your/layout_script');
(via these docs)
EDIT: I should mention that the path is relative to whatever your layout directory is (by default, it's application/layouts/scripts/)
You can also use like this
// Within controller
Zend_Layout::getMvcInstance()->setLayout('layout_name');
//Within view script
<?php $this->layout()->setLayout('layout_name'); ?>
Your layout must be in /layouts/scripts/ folder, otherwise you need to specify the path also. No need to write .phtml, just name of the layout

Categories