I want my url to change from this
/examinations/getchoices/page:2
to this
/examinations/getchoices/item/2
I wonder how to do this. I've already tried changing in the routes.php. I've tried the tutorial in this site. The page content doesn't change when I click prev or next links.
This is what i got in the url
/examinations/getchoices/ 2/ 2
My version of cake is 2.1.
Your help will be much appreciated. I've been stuck with this for 2 days already. Thank you.
You can define custom routes.
http://book.cakephp.org/2.0/en/development/routing.html
e.g.
Router::connect(
' /examinations/getchoices/item/:number',
array('controller' => 'examinations', 'action' => 'getchoices'),
array('pass' => array('number'))
);
let me know if i can assist you more
Related
I am trying to hide a field based on what user is selecting from a entity referenced checkbox list but no matter what I do I cannot hide the field.
I think some issue with the selector.
$form['title']['#states']['invisible'][] = array(
'input[name="field_offering_course[und][0][target_id]"' =>array('checked' => TRUE));
You are missing a bracket:
'input[name="field_offering_course[und][0][target_id]"]' =>array('checked' => TRUE));
I can't help more than that...not very experienced in php :D
I have a CakePHP 2.5 site running with CakeDC/I18n plugin to allow for multi language support. I have installed the plugin to use a 3 letter prefix when switching languages:
www.example.com/eng/
This is working fine when I click a button to change languages. The language prefix is added to the url. The problem is when I switch pages by clicking on a link the prefix is dropped. Why would this be happening? Do I need to do something in the href markup? My understanding is that the CakeDC/I18n plugin would take care of this.
Any help would be greatly appreciated as I have been scratching my head with this one for awhile!
You need to pass as parameter the current language.
Otherwise it'll always use the default language that you defined in the bootstrap.php
Here is an example.
Router::url(
'lang' => 'spa',
'controller' => 'articles',
'action' => 'view',
'slug' => 'test'
);
I have the following code " which is not quite correct" in a part of a list view in my component. For Joomla 3.4
<td style="text-align:center">
<?php echo JDom::_('html.fly', array(
'dataKey' => 'link',
'dataObject' => $row,
'href' =>array($row->link),
'target' => '_blank'
));?>
I am trying to get the link from the field called link , but every thing I have tried either places the sites url before the link, does nothing or just goes back to the front page of the site. The link field contains a link to another website.
Can someone help me with this code snippet?
I'm working on a webshop. In the categories view we load the products in with jquery because the user is able to filter them. This works great.
We then tried to save the page the user was on (in the pagination), so that if he views a product and gets back to the categorie view, he starts on the page he was previously on. For example, I'm on pagination page 3, view a product, hit the browser back button, and continue on page 3 instead on 1 (which is default cakephp behaviour). We save the page number in a session, which works great as far as we can see. Then we read that pagenumber from the session and use it in our $this->paginate as 'page' => $pagenumber. This also works.
But there is one weird problem. When you start on page 2 or 3 (read: any page bigger than 1, but we only have 3 pages at the moment), you can't get back to page 1. Switching to page 2 or 3 works great, but you can't switch to page 1. If you click on it nothing happens, it does send a network request thingy in the chrome element inspector so something is happing in the background. If we manually set the page to 'page' => 1. It works, you can switch to all 3 pages.
I hope you understand my problem, I tried to explain it as best as I can. (Sorry if my English isn't too good, I tried the best I could).
My code (I made it as short as possible without fields en joins):
In the controller
$page_number = $this->Session->read('Pagination.currentpage');
$this->paginate = array(
'conditions' => array(
'Product.status' => 'active',
'Product.visibility' => 1,
'Product.hidden_on_site' => 0,
),
'order' => 'Product.name ASC',
'limit' => 20,
'recursive' => 2,
'page' => $page_number,
);
The $page_number works, it outputs the right page. But it gives the problem that you can't get tot page 1 if you're on page 2 or 3. If we manually set 'page' => 1 it works.
I hope you have a clue or a solution that works in an other way...
The CakePHP 2.x PaginationRecall Component works very well for this purpose. I use it in several of my projects.
Author is SO member Athanassios Bakalidis.
I am trying to build a FAQ page, with table of contents on top and answers below it. I would like to click on a question from the table of contents and link on the same page to the corresponding answer. How can I do this in CakePHP, by using $this->Html->link() method?
Thank you!
use something like this for the link:
$this->Html->link($question_title, $this->here . '#question-' . $question_id);
and then for later down the page put the answers in something like
<div id="question-<?php echo $question_id; ?>"><?php echo $answer_text; ?></div>
obviously the vars will be something like $question['Question']['title'] in cake and the Html->link url could be done with an array like
$this->Html->link($question_title, array('action' => 'faq', '#' => 'question-' . $question_id));
just as long as the url part before the # exactly matches the current url.