Page 1 of 1

Newbie: serendipity_event_entrypaging Third placement option

Posted: Tue Mar 16, 2010 6:24 pm
by Stosh
Hi,

Post-POST-script -- Well, I got it all working (see below) but now have a bu(er...)Feature report. The "prev/next" pagination currently doesn't skip over entries for which the user has no access. That is:
  1. It produces a next or previous link to an entry that is not accessible by the user, and
  2. if the user clicks on the link it will put up a "No entries to display" page, which would be fine, except
  3. prev/next page options will no longer appear on the inaccessible entry, so the viewer will have hit a dead end.
It would be great to just not show these links in the prev/next feature to begin with.


= = = = =
Post-script: I followed my own advice (below) and it worked (with a bit more granularity than I expected :) ). Now I'm wondering what the little "true" is for, on the end of '...|truncate:30:"...":true'


= = = = =
I really did search around for this. I'm sure it's out there somewhere, but I couldn't come up with the right search string on this one.

The serendipity_event_entrypaging plugin installed fine, and I was able to easily place it at the top of the page.

I'd like to put it in my own div class though, and I'm fairly sure that the third option in the "Placement" drop down alludes to how I do this.

The third option says:


Smarty {$pagination_(next|prev|random)_(title|link)}

I'm assuming this means I can put something like this:

{$pagination_prev_title}

in the entries.tpl and it will display a link to the "previous" entry (however it is defined in the plugin).

Is this right? Do I need to preface this with "$smarty.pagination..." or any similar thing? Or can I just put the above code (or similar) wherever I want it in the template?

Question 2: Will this automatically include the > < parts produced by the first two options?

Thanks.

-s

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Tue Mar 16, 2010 8:06 pm
by garvinhicking
Hi!

Yeah, reading the ACL/permission systems into the query would make it fairly complex. I do see a use for that though, at least a asn option...

Regards,
Garvin

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Tue Mar 16, 2010 9:47 pm
by Stosh
Garvin,

Cool. Hoping you get inspired :)

For now, I'm wondering if there are workarounds I can use.

1. Are there other values I can access through the $pagination_(next|prev|random)_ variables?

2. If I can get the first category of _prev, or _next perhaps I can do something to skip over it if it has a specific naming convention (one that denotes "restricted").

3. Just curious really, what is the ":true" used for in a variable like {$example|truncate:40:"...":true} ?


Post-script - Just had a great idea! ! ! (i think). If you could just give me a way to get only entries in the top-level categories, as we did a while back for the category listing plugin (http://board.s9y.org/viewtopic.php?f=2&t=16006), that would solve everything. In that case, I could simply check the category-level (recalling from memory). Here there'd have to be a way to check the category of the _prev and _next and skip over it if it were anything other than level 0...


Thanks for all the help.

-stosh

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Wed Mar 17, 2010 4:27 am
by Stosh
Garvin,

I worked up a solution, though it probably only works for me.

It works for me because:

1. I only show the top-most level of categories, and reserve the next level down for security categories.

2. I don't need to page through single entries when I'm logged in (i.e., it is only going to be for visitors).

With that in mind, here's the changes made to the serendipity_event_entrypaging.php file:

Code: Select all

            // IMeMy changed 20100316, was: $cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . $this->timeOffset(time());
            $cond['and'] = " AND c.parentid = 0 AND e.isdraft = 'false' AND e.timestamp <= " . $this->timeOffset(time());
            serendipity_plugin_api::hook_event('frontend_fetchentry', $cond);
            if (serendipity_db_bool($this->get_config('use_category')) && !empty($currentTimeSQL['categoryid'])) {
                $cond['joins'] .= " JOIN {$serendipity['dbPrefix']}entrycat AS ec ON (ec.categoryid = " . (int)$currentTimeSQL['categoryid'] . " AND ec.entryid = e.id)";
            }
            else { // IMeMy added 20100316
                /*
                 *  JOIN {$serendipity['dbPrefix']}entrycat AS ec
                 *      ON (ec.entryid = e.id)
                 *  JOIN {$serendipity['dbPrefix']}category AS c
                 *      ON (c.categoryid = ec.categoryid)
                 *
                */
                $cond['joins'] .= "JOIN {$serendipity['dbPrefix']}entrycat AS ec ON (ec.entryid = e.id)  JOIN {$serendipity['dbPrefix']}category AS c ON (c.categoryid = ec.categoryid)";
            }



Everything else remains the same.



-stosh

p.s. How do I get the code box to have a horizontal scroll?

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Wed Mar 17, 2010 1:39 pm
by garvinhicking
Hi!

Nice solution for your case!

I'm currently lacking a test-environment to do this with, but the "final" solution would be something like this:


Currently the plugin fetches the entry with this query:

Code: Select all

...
            $cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . $this->timeOffset(time());
            serendipity_plugin_api::hook_event('frontend_fetchentry', $cond);
...
This hooks into some additional query code (placed into $cond) to query some extra-stuff. However it does not fetch the ACL privileges.

For that, it requires the code call

Code: Select all

    $cond['and'] = " AND e.isdraft = 'false' AND e.timestamp <= " . $this->timeOffset(time());
    serendipity_ACL_SQL($cond, true);
    serendipity_plugin_api::hook_event('frontend_fetchentry', $cond);
This *could* make trouble though because this code:

Code: Select all

            if (serendipity_db_bool($this->get_config('use_category')) && !empty($currentTimeSQL['categoryid'])) {
                $cond['joins'] .= " JOIN {$serendipity['dbPrefix']}entrycat AS ec ON (ec.categoryid = " . (int)$currentTimeSQL['categoryid'] . " AND ec.entryid = e.id)";
            }
Also performs a join on entrycat with the same prefix, but a different join outcome. So maybe we would need some code that inspects $cond['joins'] to see if entrycat is already joined, and if that is the case, only do a "WHERE ec.categoryid = currenttimeSQL[categoryid]" instead of joining it...

Regards,
Garvin

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Wed Mar 17, 2010 4:26 pm
by Stosh
Garvin,

Just can't leave a job undone, can you? :wink:

I'll be switching to your solution just as soon as you get it out of the nursery. It will be nice to have a consistent browsing experience whether logged in under security, or not logged in.

-s

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Thu Mar 18, 2010 10:33 pm
by Stosh
Garvin,

re: "I'm currently lacking a test-environment to do this with, but... "

I may have been insensitive and thoughtless there. If you need a testing environment, my site is currently not getting visitors (beyond the usual comment spammers).

Sorry, if this is what you were getting at. It flew right past me.

-stosh

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Fri Mar 19, 2010 9:43 am
by garvinhicking
Hi!

Sure, if you have an environment I could try to implement a patch so that you could try it with different kinds of configurations (especially once without the option "Use catebory-based restrictions" in the s9y configuration, and once without the entryproperties plugin being active, and then with both being disabled *g*).

I've prepared this file:

http://nopaste.info/9247c18211.html

Regards,
Garvin

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Wed Mar 24, 2010 5:46 pm
by Stosh
Garvin,

I've just uploaded it into the plugins directory. Here is my list:

Entry properties plugin NOT installed:
  • Category-based-page: NO:
    • Logged in: Next/Last links navigate to restricted entries.
    • Logged out: Next/Last don't include restricted entries and skip over
  • Category-based-page: YES:
    • Logged in: Next/Last stays in category. includes restricted entries.
      BUT: If there are only two entries in the RESTRICTED category, it gives a BACK button, but then no FORWARD button when you navigate there. This is also true if you start at the older entry (no FORWARD to the newer entry).
      ****If the category with only two entries is not restricted it will display them properly.
    • Logged out: Seems to work fine, including for categories with only two entries (no BACK-button problems).
I don't have the entry properties plugin. I have recently changed my PHP settings and will try again to install it... We'll see. As far as I can see, there is only one bug in that an earlier restricted entry will not generate a navigation (FORWARD) anchor to the new entry when there are only two entries in the category.

Almost forgot

My entries.tpl has had the following code inserted where I wanted the to/fro links to be (top)

Code: Select all

        <div class="serendipity_entryFooter">
            {if $pagination_prev_link}
                <<   
                <a href="{$pagination_prev_link}">{$pagination_prev_title|truncate:40:"..."}</a><br />
            {/if}
            {if $pagination_next_link}
                <a href="{$pagination_next_link}">{$pagination_next_title|truncate:40:"..."}</a>   >>
            {/if}
        </div>

My activity list will be.

1. Install the entryproperties plugin you want to test with
2. Get you a login (if you want it)

-s

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Mon Mar 29, 2010 4:36 pm
by Stosh
Garvin,

More clarification:

The "forward" link misses the latest entry in any list, whether categories or all. That is:

If there are five entries and you go to individual entries on the most recent one you will see a "back" link.

Follow that link to the next one, and there will still be ONLY a "back" link (no forward link).

Follow the "back" link again, and you will get a back and forward link.

It only shows a forward link to the penultimate (where ultimate means most recent :mrgreen: ) entry in the list.

Test this here. If you go into the top most entry: "Visual Cortext Reacts In Response to Novelty (but not to this study)", and then use the back button, there will be no forward button.



-stosh

Re: Newbie: serendipity_event_entrypaging Third placement option

Posted: Tue Mar 30, 2010 12:44 pm
by garvinhicking
Hi!

A login would be great because I'm currently lacking the opportinuty to setup a test installation to debug this...

Regards,
Garvin