Pagination on Propel ORM - pagination

i paginated the propel results, its all working fine, but i cant get this thing working. I will really appreciate any help or workaround this issue:
<?if ($posts->getPage()==???) { ?>
next
<?}?>
the function getPage() returns to me the active page, but what should i put on the ??? to hide the last next link on propel, some function like $posts->getLastPage() that actually works. I just cant get any info about this on the Propel documentation.
to hide the first 'previous' link, i used this:
<?if ($posts->getPage()>1) { ?>
prev
<?}?>

getLastPage() will return the page number of the last page. atLastPage() is a convenience function that will already do the comparison for you, and also exists as atFirstPage(). See the API docs for Propel 1.3, 1.4, 1.5 or 1.6.
You code could look like this:
<?php if (!$posts->atLastPage()) { ?>
next
<?php } ?>
I assumed $linkPrevNext contains just the page numbers, like it came from $posts->getNextLinks(). If not, you should not use getLastPage() in the link of course.

Related

Joomla 2.5 disable pagination?

I built a component in joomla 2.5 (back end) and even if I don't include code for pagination, my results aren't displayed fully (they are limited to about 20). Is there a way where I can have all my results show on default? Or in other words disable pagination? Thanks!
In your list model, set the list.limit state accordingly. By default it will use the global list limit.
You can use this code in the populateState() function:
$this->setState('list.limit', 0);
Please note that if you call parent::populateState($order, $dir);, this will also set the list.limit. So you either don't call the parent function or your set the state after the parent function was called.
firstly open your custom component view file, which is located in
/components/component_name/views/tmpl - file name is default.php and now comment this line
<?php echo $this->loadTemplate('_header'); ?>
and also
<?php echo $this->loadTemplate('_footer'); ?>
may very much help!
or another way is that goto joomla administrato - site - globle confi - Default List Limit
change limit

How to display modules only on search results in Joomla 2.5?

Hello please read the whole question, this isn't just solved by enabling the modules only for the search page:
I have a few modules that are exclusively shown on the search page in Joomla.
I created a hidden menu entry for the search as well in order to tell modules to only show on this page. This works alright, but when I click one of the results and get redirected to the actual result, then the modules, which should only show up on the search page are still shown in the result page.
Any clue how to fix this? Really annoying as I use 3rd party search enhancing modules, and they are showing on the results.
Using standard Joomla, there's no way to target modules to only the search results page and none of the pages that link off the results – but I know you knew that! The hidden menu item is a help, but does not change the menu item of some of the links off that page. It's all to do with the allocation and use of "Itemids" in Joomla.
To be able to target modules more specifically, you need to use a 3rd-party extension. I developed MetaMod (www.metamodpro.com) to cope with exactly this use case. MetaMod is a wrapper module that can then decide just which other module to include in itself (or not). So you assign the MetaMod to the page, then put a snippet of code inside the MetaMod which decides which other module to include.
In this case, I'd use the following in MetaMod:
if ($core_genius->check("pagetype = search, searchresults")) return XXX;
// replace XXX with the module id of the module to include
// ONLY on the search page, or the searchresults page, but
// no other type of page.
Hope that helps,
Stephen
Although MetaMod is great (I've used it myself & Stephen's support is great!) there is another way to do it without using 3rd party extensions.
You could create new module positions in your template above (or below) the module positions you wanted to use and wrap them in an if statement like so:
<?php if(!isset(JRequest::getString('searchword'))) : ?>
<jdoc:include type="modules" name="right-search" style="xhtml" />
<?php endif; ?>

Pagination [+next+] not working on MODx CMS template

I'm having difficulty getting the pagination functionality working with [[Ditto? ... ]] in MODx CMS.
I have the documents displaying in the page, limit is set to 5. The output from my other pagination template placeholders seem to be working but the [+next+] link doesn't load the next set of 5 documents (going in descending date order).
Here's my template code:
[[Ditto?
&parents=`13`
&tpl=`ArticleListChunk`
&display=`5`
&&removeChunk=`Comments`
&paginate=`1`
&extenders=`summary,dateFilter`
&paginateAlwaysShowLinks=`0`
&dateFormat=`%F %D %Y`
]]
<p>Showing <strong>[+start+]</strong> - <strong>[+stop+]</strong> of <strong>[+total+]</strong> Articles</p>
<ul class="clearfix">
<li>[+previous+]</li>
<li>Page <strong>[+currentPage+]</strong> of [+totalPages+]</li>
<li>[+next+]</li>
</ul>
The output I get is:
Showing 1 - 5 of 17 Articles
Page 1 of 4
Next >
as you can see the output is correct, however when I click the 'next' link the resulting URL is .../news.html?start=5 but the content of the page stays the same (i.e. the latest 5 documents are shown!).
This is how the template and functionality was when I was inherited this project from a client, and I have never used MODx CMS before -- can anyone help me please?
I there a way to update the SQL offset with a parameter or something? I've been all through the Wiki pages for Ditto / MODx but can't find what I need or what I should be doing that I'm not!
I would think you need to call ditto uncached [[!Ditto? attribs ]]
That's just a guess.
Also it looks like you are using EVO? check the cache syntax, you might need to put an exclamation mark at the end as well. [[!Ditto? attribs !]]
After plenty of searching I found a post on the MODx forum that pointed me in the right direction.
Turns out that caching was enabled in the page/document's settings (doh!). I disabled this and now it works fine!
However I have not set the no-caching token ('!') in Ditto's parameter string which, including the answer from Sean, my research has suggested is advisable and/or required. I've not worked with MODx before so I can't say for certain, but it seems to work without this for me!
Thanks #SeanKimball as your answer set me down the right path.

Pagination With Special Recent Posts Plugin (WordPress)

I am using the 'Special Recent Posts' plug-in in WordPress. It is being used to show header images and excerpts for articles, which you then click through to the full article.
You can set parameters on that plug-in to tell how many recent articles you would like show. Basically what I want to do is show the first five articles on the main page and then have the overflow go to new pages (like an 'older posts' type thing where there would be five posts per page).
Can anyone help me get pointed in the right direction? Every time I Google this question it doesn't quite understand...Thanks.
EDIT:
I saw the first answer and while it is moving in the right direction, it doesn't automatically generate the new pages like I would like. I want to have the overflow of special recent posts generate a new 'previous' page automatically. I understand that I could manually do this but the blog I am working on will be getting updated every day so it would be very time consuming to constantly create new pages as I go along. Can somebody point me in the right direction?
EDIT:
Here is the full code I have on my index.php:
<?php get_header(); ?>
<?php c2c_the_category_image($image_extensions='png gif jpg', $image_dir='/wp-content/images/', $use_name_if_no_image=true, $start_from='begin', $limit=999); ?>
<?php echo do_shortcode("[srp srp_number_post_option='34' srp_thumbnail_option='yes' srp_widget_title_hide_option='yes' srp_post_date_option='no' srp_wdg_excerpt_length='50' srp_wdg_excerpt_length_mode='fullexcerpt']"); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
The plugin has a parameter for this, from the documentation:
//Global Post Offset (to skip an arbitrary number of posts from the beginning)
srp_post_global_offset_option => numeric
So, on the second page, to skip 5 posts and then show the next 5, you would want something like this:
[srp srp_number_post_option='5' srp_post_global_offset_option='5']
Documentation: http://wordpress.org/extend/plugins/special-recent-posts/installation/
EDIT: To answer your question about generating new pages, technically you would not. You would have one page that would show different posts, acting like it was a different page. You would probably need use a query string (URL parameter). But, you can't put direct PHP into a wordpress post, so you need to either modify a PHP file, or get a WordPress plugin like Shortcode Exec PHP, so you can take the page number parameter from the URL and put it into the shortcode for special recent posts.
Example based on your index.php code:
$offset = ($_GET['page'] * 5) - 5;
echo do_shortcode("[srp srp_number_post_option='34' srp_thumbnail_option='yes'
srp_widget_title_hide_option='yes' srp_post_date_option='no'
srp_wdg_excerpt_length='50' srp_wdg_excerpt_length_mode='fullexcerpt'
srp_post_global_offset_option='".$offset."']");
Make your first page use
index.php?page=1
And your "Next Page" link:
$next = $_GET['page'] + 1;
echo 'Next Page';
I never worked before the special recent post plugin. So i would like to give WordPress query post solution.
First, to get recent five post in home page (index.php) use below query parameter.
$query = new WP_Query( 'posts_per_page=5');
Second, to list older post in other page use below query parameter.
$query = new WP_Query( array( 'posts_per_page' => 5, 'offset' => 5 ) );
Above query will get posts from 6 and 5 post per page.To add pagination, add paging parameter.Refer WP_Query
Pagination is now available in the new Special Recent Posts PRO Edition version 3.0.0

Webmatrix Layout -- Inserting into head?

I've created a web site using Asp.Net and the Razor view engine (which is the same as using WebMatrix). Up to now, I've been using SQL to query databases directly, but now I have a page which needs to query a WCF service that returns XML (getting that to return JSON or ODATA maybe is for a separate question).
On doing this, I was looking at the best way to do this, and it seems that jQuery may be the answer (unless you have other thoughts).
The problem is I'm using SiteLayout using the Layout="~/SiteLayout.cshtml" and I can't work out how to override or insert extra information specific to this page into the head tag that is in the SiteLayout, such as the script I need to add?
I'm pretty sure I'm thinking about this wrong, so if anyone has the answer to point me in the right direction, that would be great.
Thanks in advance for any assistance.
You can to define a Head section in the child pages:
#section Head {
<script> ... </script>
}
You can then call RenderSection("Head") in the <head> in the layout page to render this section.
You may want to pass , required: false.
For more information, see ScottGu's blog post

Resources