Laravel 4 pagination tags change - tags

Is some way to change structure pagination tags in Laravel 4?
I am creating the pagination links using the links method:
<?php echo $data->links(); ?>
HTML is like this:
<div class="pagination">
<ul>
<li>
1
</li>
<li>
2
</li>
</ul>
</div>
For example remove unordered HTML list?

Edit app/config/view.php and change the pagination option to be one of your views, like 'pages'.
The create your pages.php view.
The default pagination is below. I'd start with that and start tweaking it as you need.
<?php
$presenter = new Illuminate\Pagination\BootstrapPresenter($paginator);
$trans = $environment->getTranslator();
?>
<?php if ($paginator->getLastPage() > 1): ?>
<ul class="pager">
<?php
echo $presenter->getPrevious($trans->trans('pagination.previous'));
echo $presenter->getNext($trans->trans('pagination.next'));
?>
</ul>
<?php endif; ?>

Related

Zend Navigation - Add a HTML element in the hyperlink

What's the best way to add some HTML elements in the hyperlink of the Zend Navigation menu?
I would like to add a SPAN element only in the first children of the menu for having the following structure:
<ul>
<li><span></span>home</li>
<ul>
<li>users</li>
<li>staff</li>
</ul>
<li><span></span>support</li>
....
You can create you own template for the navigation like the following:
<?php $navigation = $this->navigation('Navigation')->getContainer();?>
<ul>
<?php foreach ($navigation as $page):?>
<li><span></span><?php echo $page->label;?></li>
<ul>
<?php $subPages = $page->getPages();?>
<?php foreach ($subPages as $subPage):?>
<li><?php echo $subPage->label;?></li>
<li><?php echo $subPage->label;?></li>
<?php endforeach;?>
</ul>
<?php endforeach;?>
</ul>
Just save it in a view file and then include it in your layout with the code below:
<?php echo $this->partial('layout/nav.phtml'); ?>
Another possible solution is to use the renderPartial or setPartial methods of the navigation view helper as described here: http://framework.zend.com/manual/2.2/en/modules/zend.navigation.view.helper.menu.html#rendering-a-custom-menu-using-a-partial-view-script

bootstrap codeigniter form input and submit button

I am trying to go along with bootstrap and Codeigniter, but I am having a little problem, I cant seem to figure out how to align 3 simple elements into one row, so they are aligned perfectly next to each other.
I want my H3 tag, input field and my submit button from my form to be next to each other. I have already tried the span4 on the 3 objects within divs, then also display:inline, but nothing works correctly. I dont know why, but If I want them to be perfectly next to each other, I just have to put there margin-top: -7px and other margins on the other objects but this looks like a not a good approach on this matter at all. Could you please help me ? !
My code:
<div class="well">
<h3>My superb h3 tag!</h3>
<?php echo form_open('search/quick_search'); ?>
<?php echo form_error('search_query'); ?>
<?php echo form_input('search_query','','placeholder="Search query"'); ?>
<?php echo form_submit('submit_quick_search','Search','class="btn"'); ?>
<?php echo form_close(); ?>
How does it look
This is how I've been using then together (Horizontal form)
<?php echo form_open('search/quick_search', 'class="form-horizontal');?>
<div class="control-group <?php echo form_error('search_query')? 'error' : ''; ?>">
<label class="control-label" for="search_query">Search Term:</label>
<div class="controls">
<?php echo form_input('search_query','','placeholder="Search query"'); ?>
<span class="help-inline"><?php echo form_error('search_query'); ?></span>
<span class="help-block"></span>
</div>
</div>
<div class="form-actions">
<?php echo form_submit('submit_quick_search', 'Search', 'class="btn"'); ?>
</div>
<?php echo form_close(); ?>

how to check session in zend layout

layout.phtml:
<?php echo $this->doctype() ?>
<html>
<head>
<?php echo $this->headTitle()."\n"; ?>
<?php echo $this->headLink() ."\n"; ?>
<?php echo $this->headScript(); ?>
</head>
<body>
<div id="wrap">
<div class="header">
<div class="logo"><img src="../../images/logo.gif" alt="" title="" border="0" /></div>
<div id="menu">
<ul>
<li class="selected">home</li>
<li>about us</li>
<li>books</li>
<li>specials books</li>
<li>my accout</li>
<li>register</li>
<li>prices</li>
<li>contact</li>
<li>adddbook </li>
</ul>
</div>
</div>
<div class="center_content">
<div class="left_content">
<?php echo $this->layout()->content ?>
I am new to zend framework here i am facing problem with displaying navigations. in pure php i can serve my navigation by checking sessions. like this:
<?php
if($_SESSION['usertype']=='admin')
{
echo "<li>adddbook </li>";
}
?>
My question is how can i implement this in zend framework. Thanks
You can do this in a myriad of ways like the Zend_Auth, but the closes to the $_SESSION method is using Zend_Session.
First you need to start Zend_Session before any output is sent to the browser, just like a normal php session. I do it in my index.php right after setting all my paths and autoloaders.
Zend_Session::start();
Next step is creating a namespace for the userinformation and adding the relevant information to it, preferably when you authenticate the user.
$userInfo = new Zend_Session_Namespace('userInfo');
$userInfo->userType = 'admin';
This is the equivalent to setting a $_SESSION['userInfo']['userType'] = 'admin';
Last, get the information in your layout:
<?php
$userInfo = new Zend_Session_Namespace('userInfo');
if($userInfo->userType=='admin')
{
echo "<li>addbook </li>";
}
?>
Read this link for more information http://framework.zend.com/manual/en/zend.session.html
If you want to check an user role, you could use the class Zend_Auth provided by the framework. You can check the credential of a user and then affect it a role.
To retrieve this role you can check the identity of the user with the Zend_Auth instance :
$identity = Zend_Auth::getInstance()->getIdentity();
if (strcmp($identity->role, "admin") == 0) {
echo '<li>adddbook </li>';
}

Zend Layout Double Div

Hi i want to put two div in a zend view. After i want to have the two div in different position. My problem is that i want to have the normal content adn i want to add another div that rapresent the side menu
For example my view is:
<div id="view-menuscritte">
List menu
</div>
<div id="view-content">
<?php
echo $this->errorMessage;
echo $this->form;
?>
</div>
When I use in my layout
<div id="menu">
<img id="menusopra" src=<?php echo $this->baseUrl().'/img/menusopra.jpg'; ?> >
<div id="menuscrittegenerale">
<?php echo $this->layout()->menuscritte; ?>
</div>
<img id="menusotto" src=<?php echo $this->baseUrl().'/img/menusotto.jpg'; ?>
</div>
<div id="contentgenerale">
<?php echo $this->layout()->content; ?>
</div>
The problem is that the two div (->content and ->menuscritte) are in the same div.
view-menuscritte is not in menuscrittegenerale where it could be.
Inside folder of layout.phtml , create menu.phtml
cut and paste following content from your view into menu.phtml
<div id="view-menuscritte">
List menu
</div>
Now in your layout.phtml replace
<?php echo $this->layout()->menuscritte; ?>
with
<?php echo $this->partial('menu.phtml);?>

Doctrine2 large collections

I have been playing with doctrine2 + ZF setup for the last couple of days.
One of the things I still can't figure out is the large array collection assosicaitons. For example let's say we have an entity called Post and each post can have many comments.
<?php
/**
* #Entity
*/
class Post
{
/**
* #OneToMany(targetEntity="Comment", mappedBy="post")
*/
protected $comments;
}
?>
Now this will load all comments if I do
$post->comments
But what if there are, say 10000 comments for this particular post? Then all will be loaded which is not good. And as far as I know slice/pagination will not be available until doctrine 2.1.
Can someone advice me how I can paginate comments? With DQL maybe? if DQL, where do you implement this?Do I create a getComments method in the Post entity and do the DQL there?
Thanks
Bill
I'm using pagination from https://github.com/beberlei/DoctrineExtensions, it works great, at least for me.
Edit: Not sure this will help you, but here's how I did my pagination
Controller
// Create the query
$qb = $this->_em->createQueryBuilder();
$qb->select('p')
->from('Identiti_Entities_Pengguna', 'p');
// Sorting
$qb->addOrderBy('p.' . $input->sort, $input->dir);
$q = $qb->getQuery();
// Pagination
$itemPerPage = 100;
$records = new Zend_Paginator(
new DoctrineExtensions\Paginate\PaginationAdapter($q));
$records->setCurrentPageNumber($input->page)
->setItemCountPerPage($itemPerPage)
->setPageRange(10);
$this->view->records = $records;
View
<?
echo $this->paginationControl($this->records,
'Sliding',
'partials/pagination.phtml');
?>
pagination.html
<?php if ($this->pageCount): ?>
<ul id="pagination-digg">
<li class="previous">Pages: <?=$this->pageCount?></li>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li class="previous"><a href="<?php echo $this->url(array('page' => $this->previous)); ?>">
< Previous
</a></li>
<?php else: ?>
<li class="previous-off">< Previous</li>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<li>
<a href="<?php echo $this->url(array('page' => $page)); ?>">
<?php echo $page; ?>
</a>
</li>
<?php else: ?>
<li class="active"><?php echo $page; ?></li>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<li class="next">
<a href="<?php echo $this->url(array('page' => $this->next)); ?>">
Next >
</a>
</li>
<?php else: ?>
<li class="next-off">Next ></li>
<?php endif; ?>
</ul>
<?php endif; ?>
You may consider implementing Zend_Paginator_Adapter_Interface.
See ZF docs for more details:
Zend Framework: Documentation: Advanced usage - Zend Framework Manual
Doctrine 2.2 now has a Paginator class. See this link for how to use it with Zend_Framework:
Reply to How to use D2's Paginator with Zend_Paginator