how to make the paginator style clickable? - cakephp

I've added a class to style the Paginator to make it look like a button, but the only clickable area is the text inside , is there any way to fix that ?
<?php echo $this->Paginator->next('next >>', array('class'=>'Paginator')); ?>

if you use the cake.generic.css by default this is the form to make this.
<?php
echo "<div class='paging'>";
echo $this->Paginator->prev('<< ' . __('anterior ', true), array(), null, array('class'=>'disabled'));
echo $this->Paginator->numbers(array( 'class' => 'numbers' ));
echo $this->Paginator->next(__(' siguiente', true) . ' >>', array(), null, array('class' => 'disabled'));
echo "</div>";
?>

Related

simple blog with croogo

I is not What is the problem, I made a simple blog in Croogo, the problem is it is not adding or modifying or delete, because Arabic language ??
function add in controller
`public function admin_add() {
$this->set('title_for_layout', __('Add Part'));
if (!empty($this->request->data)) {
$this->Part->create();
if ($this->Part->save($this->request->data)) {
$this->Session->setFlash(__('The Part has been saved'), 'default', array('class' => 'success'));
$this->redirect(array('action' => 'index'));//, $this->Part->id));
} else {
$this->Session->setFlash(__('The Part could not be saved. Please, try again.'), 'default', array('class' => 'error'));
}
}
}`
=>
model
`class Part extends AppModel {
public $name = 'Part';
var $belongsTo = array(
'Market' => array(
'className' => 'Market',
'foreignKey' => 'market_id',
)
);
protected $_displayFields = array(
'id',
'num_part',
'prix_part',
'prop_Pledge',
'prix_Pledge',
);
}
`
add view
<?php $this->extend('/Common/admin_edit'); ?>
<?php echo $this->Form->create('Part');?>
<fieldset>
<div class="tabs">
<ul>
<li><span><?php echo __('Part'); ?></span></li>
<?php echo $this->Layout->adminTabs(); ?>
</ul>
<div id="role-main">
<?php
echo $this->Form->label('num_part', 'العدد : ');
echo $this->Form->input('num_part',array('label' => false ));
echo $this->Form->label('prix_part', 'االمبلغ : ');
echo $this->Form->input('prix_part',array('label' => false ));
echo $this->Form->label('prop_Pledge', 'إقتراح التعهد : ');
echo $this->Form->input('prop_Pledge',array('label' => false ));
echo $this->Form->label('prix_Pledge', 'مبلغ التعهد : ');
echo $this->Form->input('prix_Pledge',array('label' => false ));
?>
</div>
<?php echo $this->Layout->adminTabs(); ?>
</div>
</fieldset>
<div class="buttons">
<?php
echo $this->Form->end(__('Save'));
echo $this->Html->link(__('Cancel'), array(
'action' => 'index',
), array(
'class' => 'cancel',
));
?>
</div>
message error : The requested address was not found on this server.
I don't think it is because of Arabic language because when you do :
echo $this->Form->label('prop_Pledge', 'إقتراح التعهد : ');
The second parameter is a text. I don't know which Cake version you're using but I think that the first field should be Part.prop_Pledge (Cake v3).
I suggest you to try to use debug() and exit to see where is the real problem or try to put remove arabic characters to see if this is the reason of you're problem.
Just a question where is your $this->Form->create() in view ?
line added to the database successfully but does not retoure to index
it displays an error message
Could you print the message error hello21 please ?
Hope this will help you.

How to customize CakePHP pagination url?

currently i am using cakephp version 2.5.3
I want to change my cakephp pagination url.
My current URL is http://www.example.com/newsFeeds/ajax_news_feed/page:2 I need http://www.example.com/newsFeeds/index/page:2
My Code:
<?php
echo $this->Paginator->prev(' <<' . __('Previous '), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers();
//echo $this->Paginator->url(array('controller'=>'newsFeeds', 'action'=>'index'));
//echo $this->Paginator->link('Sort by title on page 5', array('controller'=>'newsFeeds', 'action'=>'index'));
echo $this->Paginator->next(__(' Next') . '>> ', array(), null, array('class' => 'next disabled'));
?>
Above pagination is showing-
When i am clicking 2 then the link is going to http://www.example.com/newsFeeds/ajax_news_feed/my_post/page:2 but i need http://www.example.com/newsFeeds/index/my_post/page:2
Please tell me how to change controller and action in pagination?
User $this->Paginator->options-
Code:
<?php
$this->Paginator->options['url'] = array('controller' => 'newsFeeds', 'action' => 'index/my_post');
echo $this->Paginator->prev(' <<' . __('Previous '), array(), null, array('class' => 'prev disabled'));
echo $this->Paginator->numbers();
echo $this->Paginator->next(__(' Next') . '>> ', array(), null, array('class' => 'next disabled'));
?>
For cakephp 3 its a little bit different:
$this->Paginator->options([
'url' => [
'controller' => 'newsFeeds',
'action' => 'index',
'my_post']
]);

Ajax-pagination triggers only once

i implemented the pagination-components according to the official documentation:
http://book.cakephp.org/2.0/en/core-libraries/components/pagination.html
I also included ajax-support. Basically everthing works fine except one thing: If i switch from page 1 to page 2 the ajax-request will work, after that i switch from page 2 to 3 instead a ajax-request a normal Post-Request will be performed. So the ajax-thing works only once.
My controller looks like this (short form):
public $components = array('Paginator', 'RequestHandler');
public $helpers = array('Js', 'Categorie');
....
$this->Paginator->settings = array(
'limit' => '15'
);
No the more important thing is my view: (jquery are included in my layout...)
$this->Js->JqueryEngine->jQueryObject = 'jQuery';
$this->Paginator->options(array(
'update' => '#paginate',
'evalScripts' => true,
'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false))
));
?>
<?php
echo $this->Html->image('indicator.gif', array(
'id' => 'busy-indicator'
));
?>
<div id="paginate">...display data...</div>
<?php
echo $this->Paginator->numbers();
echo $this->Paginator->prev('« Previous', null, null, array('class' => 'disabled'));
echo $this->Paginator->next('Next »', null, null, array('class' => 'disabled'));
echo $this->Paginator->counter();
?>
That's all... as mentioned before: Switch Page 1->2 will work, Switch Page 2-3 will do a normal POST-Request, Switch 3-4 will work and so one...
A bit strange, so any idea? Btw. i tried different jquery-versions without any effect (currently i am using 2.0.3...)
Thanks - Best regards
Teyhouse
In this case, you just needed to also have:
<?php echo $this->Js->writeBuffer(); ?>
In your app/View/Layouts/ajax.ctp file.

CakePHP Form Action Button

I am trying to place a non form related button into the view for a registration button to direct people to a controller action but i continue to get error500 internal error. Any ideas what i am doing wrong here?
<?php
echo $this->Form->create('User');
echo $this->Session->flash();
echo $this->Form->input('username', array('label' => false, 'div' => false, 'class' => 'w-icon validate[required]'));
echo $this->Form->input('password', array('label' => false, 'div' => false, 'class' => 'w-icon validate[required]'));
echo $form->button('Register', array('type' => 'button', 'class' => 'button red tiny'));
echo $this->Form->submit('Login', array('class' => 'button blue tiny'));
echo $this->Form->end();
?>
$form->button is CakePHP 1.2 syntax, $this->Form is 1.3 onwards.

CakePHP 2.1 + AJAX Search / JsHelper

I try to create an Ajax search with CakePHP using the JsHelper. The Ajax request triggers but it never returns values:
Search form (find_entries.ctp):
<?php echo $this->Form->create('Entry');?>
<?php echo $this->Form->input('title', array('div' => false, 'empty', 'label' => false, 'placeholder' => 'Search'));?>
<?php echo $this->Js->submit('Upload', array(
'before'=>$this->Js->get('#checking')->effect('fadeIn'),
'success'=>$this->Js->get('#checking')->effect('fadeOut'),
'update'=>'#choose_options')
)
;?>
<?php echo $this->Form->end();?>
Controller:
public function find_entries(){
if(!empty($this->request->data)){
$entries = $this->Entry->find('all', array('conditions' => array('Entry.title' => $this->request->data['Entry']['title);
$this->set('entries', $entries);
if($this->RequestHandler->isAjax()){
$this->render('entries', 'ajax');
}
}
}
Partial to render (entries.ctp)
<div id="entries">
<?php foreach ($entries as $entry) :?>
<?php echo $entry['Entry']['title']; ?>
<?php endforeach ;?>
What goes wrong here? thanks!
have you created any div tag with id choose_options to render the ajax result? If not create a div tag like this in the view file.
<div id="choose_options"></div>

Resources