Problem when establishing homepage

User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

I tried to write a plugin for this. But there is still a problem with the pagination.
Last edited by Edi on Sat Dec 26, 2015 7:39 pm, edited 3 times in total.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
MaurizioB
Ssr. Bludit
Posts: 12
Joined: Mon Nov 09, 2015 12:59 am

Just a note for @tonimad: we're digging on this, since his plugin has some issues with pagination, then we realized that my hack has this problem too: if you have more posts than the maximum set to be shown in the advanced settings, the "Next page" link actually redirects to the homepage. He's working on it, maybe we'll have a new fancy plugin by tomorrow night thanks to him :)
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

At the moment I have no idea for the pagination...
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

I will wait what Diego will propose.

In the meantime the hack of Maurizio can be used together with the following hack of the file paginator.class.php at /kernel/helpers adding the key of the page with posts (in this example "page-with-posts") at line 41 and line 56:

Code: Select all

$html .= '<a href="'.HTML_PATH_ROOT.'page-with-posts?page='.self::get('prevPage').'">'.$textPrevPage.'</a>';
and

Code: Select all

$html .= '<a href="'.HTML_PATH_ROOT.'page-with-posts?page='.self::get('prevPage').'">'.$textPrevPage.'</a>';
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
tonimad
Ssr. Bludit
Posts: 16
Joined: Wed Dec 23, 2015 8:34 am

Thank you very much to everybody.

I tested the latest update of this code and it works perfect.

In my opinion, a code is better than a plugin. I think that a code is lighter, is best that to load plugins in the site.

If I'm right, many plugins in the site can do more than slow the system (php calls).

Bludit is distinguished by being a light and fast system. Do you think you?
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

tonimad wrote:If I'm right, many plugins in the site can do more than slow the system (php calls).

Bludit is distinguished by being a light and fast system. Do you think you?
I agree. I prefer simple hacks. On the other site, to make it easy, plugins can help. Therefore both should be possible. There are always different solutions...

In the meantime I finished the plugin. It uses jQuery. This can slow down the installation a little bit. I would prefer a PHP only solution, but I'm not good enough in PHP. Perhaps somebody has an idea for this part of the plugin.

Attached is version 0.1 to make it available for testing before it is in the repository.
Attachments
pagewithposts.zip
(1.94 KiB) Downloaded 182 times
Last edited by Edi on Tue Dec 29, 2015 12:42 am, edited 2 times in total.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
User avatar
Edi
Site Admin
Posts: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

P. S. If the installation is in a subdirectory the following should be used for /includes/pagination.php:

Code: Select all

<script type="text/javascript">

<?php
$key = $Page->key();
echo "var key = '{$key}';";
?>

if ( typeof $(".right").html() != "undefined" ) {

var next = $(".right").html();
var n = next.indexOf("?page");
var nextnew = '<li class="right">' + next.slice(0, n) + key + next.slice(n) + '</li>';

$( ".right" ).replaceWith( nextnew );

}

if ( typeof $(".left").html() != "undefined" ) {

var prev = $(".left").html();
var m = prev.indexOf("?page");
var prevnew = prev.slice(0, m) + key + prev.slice(m);

$( ".left" ).replaceWith( "<li class=\"left\">" + prevnew + "</li>" );

}

</script>
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
MaurizioB
Ssr. Bludit
Posts: 12
Joined: Mon Nov 09, 2015 12:59 am

Since some of us don't like messing around with jQuery to handle links (yes, Edi/clickwork-git, you too :P ) I tried to make some tests starting from my little hack mentioned before.
If you still use the new if block I suggested before in the theme's index.php, you might find out that the "Next page"/"Prev page" links (aka, paginator class in bludit kernel) won't work, since they automatically link to the bludit root, "HTML_PATH_ROOT".
So I checked out the class and added a few lines; I added the global $Url class and checked it for the whereAmI call; if it returns a page (and it should be if it's a blog page, if not there's no paginator at all), it adds the relative url using the slug() function.
It's just 160 bytes worth of editing, but, to be sure, I'm linking both the new file and the patch for the original one, referring to the latest 0.7.2 release (I wanted to attach them, but phpbb doesn't allow me .patch nor .txt files).
full file
patch

Edi: if you want, we could completely drop the js part of your plugin, use your admin panel configuration with my modifications and check if it works, then maybe make a pull request on Bludit's repo.
User avatar
tonimad
Ssr. Bludit
Posts: 16
Joined: Wed Dec 23, 2015 8:34 am

Hi guys!

Thank you for your efforts.

I have tested these solutions in my site. The solution that has worked better in my website is the solution of MaurizioB:

full file

The plugin of Edi works well, but it is true that using jquery is more "cumbersome".
Post Reply