cognidox / WordBridge

https://www.cognidox.com/
6 stars 7 forks source link

Pagination feature request #18

Open RaviOnline opened 12 years ago

RaviOnline commented 12 years ago

Hi,

Almost all Joomla sites have some sort of pagination set up for their articles. Typically a category link that when navigated to displays some leading front page articles followed by next or previous buttons. Since, WordBridge pulls and shows all the posts in one single page (that then scrolls quite a bit :) it doesn't seem to fit with overall scheme of articles on the site.

I was wondering if pagination support appeals to you and could make it in one of your forthcoming releases?

Regards, Ravi

vittala commented 12 years ago

Hi Ravi

The bridge does provide basic pagination (Older/Newer links) based on the "Feed count" setting, and the WordPress "Syndication feeds" item count.

Showing a list of page numbers may be possible when just listing the blog entries view, but is not possible when listing matching tags/categories because the WordPress API doesn't provide the required information.

We'll consider putting in pagination numbers for the main entries view.

Regards Vittal

RaviOnline commented 12 years ago

Hi Vittal,

The settings you mentioned doesn't seem to be taking any effect for me.

I checked my syndication feed count to be 10 and WordBridge set at 5. So, I should see two pages with 5 posts each but I see all my 10 posts on the first page itself. Tried changing WordBridge's feed count to something else (2) but it didn't work. Cache time out was set to 60 seconds for testing.

I also noticed the links "Older" and "Newer" come no matter what 'coz when I went to page 2 (which was blank) it still had an "Older" link for page 3 and page 3 for page 4 and so on..

I suspect it might have something to do with the cache. I don't remember exactly but maybe the two feed counts were 10 to begin with and that's how the pages got cached the first time. Now, when the time out occurs the page counts aren't being refreshed though the posts' content is!

I'm also wishing for a quick and easy way to totally expunge a blog i.e delete the MySQL table data itself somewhere in your WordBridge component's UI. In fact, (if I may suggest) if the blog isn't being used at all then "Used by the following menus:" can be replaced with "Burn this bridge.. :D" or something! :)

I was also wondering if you have any MySQL script that you must be using to clear the tables to help you with your dev testing. It would help me get around this issue quicker and confirm if this is cache related.

Regards, Ravi

vittala commented 12 years ago

Hi Ravi

The settings on WordBridge and WordPress must be the same - i.e. if you have syndication feed set to 10 in WordPress, it should also be 10 in WordBridge. The reason being the there's no indication from the WordPress side about how many items are expected in a feed. Not having the same value will cause the Older/Newer issue you're seeing.

You can clear the cache for a blog by simply setting the cache value to something like 1 second, visiting the blog, and then restoring the cache value.

We'll have a look a providing an explicit expunge data link for blogs.

Regards Vittal

RaviOnline commented 12 years ago

Hi Vittal,

From what you've said I'm deducing that if I have 20 total posts on WordPress and I set both the syndication/feed counts to 5 then WordBridge should show 4 pages with 5 posts each (with appropriate newer/older links) within Joomla. Please, confirm if my understanding is correct.

But, from what I remember syndication feed count controls the most recent X items that would be published in the rss feed i.e. it's controlling the total number of posts available to WordBridge. So, then how would the pagination work within Joomla when we aren't specifying X no. of posts/page anywhere within WordBridge?

Regards, Ravi

vittala commented 12 years ago

Hi Ravi

Yes, you should set both to 5.

WordPress allows an offset in posts to be specified on a feed URL, so older items can be retrieved. The syndication feed count in WordPress is controlling the number of items appearing in any requested RSS document - but these RSS documents can show different sets of results using offsets.

You can see it working on our blog http://www.cognidox.com/blog which has 10 items set for syndication

Regards Vittal

RaviOnline commented 12 years ago

Thanks Vittal,

It worked just like the way you said. This should go in the wiki too! :)

I was never too keen on having the pagination page numbers (though some people may find it useful to be able to jump to the last page) so what I wanted is already there! I'm off to customising css now to make the post titles, newer/older links more prominent. I've gotten used to clearing the cache by forcing the time out as well. :)

Just one small question - if I set the time out to say a very large value like 24 hours (86400) then within a day would WordBridge at least poll for any new posts while ignoring updates to posts that already exist in the cache or the new posts would also take about 24 hours to reflect in Joomla? On the same lines, what happens in case of a deletion?

Regards, Ravi

BTW, like I said I would.. I later did submit my review of WordBridge at http://extensions.joomla.org/extensions/social-web/social-edition/blog-integration/17095#rev-108818 in December but when it didn't get published for more than a week I thought maybe JED has shot it down for not being genuine 'coz I was in such awe of WordBridge.. :D

vittala commented 12 years ago

Hi Ravi

If you publish a new blog post on WordPress making the total number of published items on your WP blog go up, then the cache should be auto-invalidated, and new items show up. Edits of existing items though should be pulled from the cache until the cache expires.

Many thanks for the JED comment, much appreciated.

Regards Vittal

RaviOnline commented 12 years ago

Hi Vittal,

New doubts/issues: (Sorry, if I've been bugging too much! :)

  1. Do "page display options" in "menu manager" come under wordbridge settings? If yes, "show page heading" isn't taking any effect! Page heading is shown regardless.. as well as a custom "page heading" if specified is ignored. I checked default.php and found it checking for "show_page_title". Should it check for "show_page_heading" and probably test if a custom "page_heading" has been specified or not?
  2. Along with my live Joomla site I have a Dev version of it on my laptop where I'm testing wordbridge (on a local Apache/MySQL setup I mean.) Once I've configured it to my liking I would be pushing the setup onto the live one. Now, I was expecting if I increase wordbridge's timeout to say two days I would be able to work on customising CSS etc. without being online once I've already pulled some wordpress posts. But, it seems wordbridge needs to hit wordpress just to check if it needs to invalidate the cache even though later it may have to work with the cached posts only. This isn't letting me do any customization offline. I was wondering if you could just point me to where in the php code code I can add some temporary logic to make wordbridge work offline.

Regards, Ravi

RaviOnline commented 12 years ago

(3) Your wordbridge posts at cognidox.com are showing along with their dates. My date spans are coming empty so I checked the wordbridge posts table to find that post_date col for all is set to 0 = 00:00... This probabaly happened 'coz my wordpress's date settings were using a custom date format (January 22nd, 2012 instead of January 22, 2012.) But, even though I've reverted back to defaults a cache time isn't helping me reset the post_date columns! What should I do to resolve it?

Thanks, Ravi

vittala commented 12 years ago

Hi Ravi

For (1), yes, change 'show_page_title' to 'show_page_heading' - this setting had changed name in the transition from Joomla 1.5 to 1.6, and wasn't reflected in our J1.6 templates. It'll be fixed in the next release.

For (2), edit components/com_wordbridge/helpers/helper.php and set the default for $useStored to true for the getBlogInfo method.

For (3), I don't see that a custom date format matters, since the RSS feed which the blog is pulled out with should be formatted in the RFC822 date/time specification by WordPress. If you pass over the URL for your WordPress blog, I can test to see if I have the same behaviour. I would have thought clearing the blog's cache should restore the dates as the post entries are rebuilt (it's just taking the RSS date and passing it through to Joomla's date parser).

Regards Vittal

RaviOnline commented 12 years ago

Hi Vittal,

(1) Yes, the change worked as expected. In your next release, I hope the custom "page_heading" text is being checked too. I would request that "blog_title" be hidden as well if "show_page_heading" is off.

(2) This worked well as well. However, pagination stops working if $useStored is true. In my case, the cache had 3 pages with a total of 9 posts (3 per page) but I could only see the first 3 posts (on first page) when offline. This is just for your information as it didn't bother me at all 'coz I was working only on the CSS.

(3) This issue has to do with Windows platform and PHP's strftime() function. Your DEV setup seems to be a non-Windows one. On Windows, PHP's strftime() function doesn't support *nix specific conversion specifiers like %e, %F, %T used in WordBridge.

To get around this, I've replaced all strftime() calls with strftime_wb() which uses simple str_replace to get a new format string supported on windows before calling strftime() on it. I added this method to helpers.php and had to invoke it everywhere as WordbridgeHelper::strftime_wb() which I'm not sure is a clean enough approach as I hardly know any PHP. I think, I also need to use PHP_OS somewhere to make sure it's platform neutral and works when I push this setup on my non-windows Joomla hosting.

Really, looking forward to your next release or just these issues fixed in your latest beta version for me! :D

Thanks, Ravi

RaviOnline commented 12 years ago

Here's the final strftime_wb() method I'm using now:

/**
 * strftime_wb
 * Fixes non-Windows conversion specifiers found in format string before calling strftime
 * Ravi.co.in (1/26/2012 5:15 PM) strftime fix
 */
function strftime_wb($format, $ts = null) {
    if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
        $mapping = array(
            '%n' => '\n',
            '%t' => "\t",
            '%h' => '%b',
            '%e' => '%#d',
            '%P' => '%p',
            '%r' => '%I:%M:%S %p',
            '%R' => '%H:%M',
            '%T' => '%H:%M:%S',
            '%F' => '%Y-%m-%d',
            '%D' => '%m/%d/%y',
        );
        $format = str_replace(
            array_keys($mapping),
            array_values($mapping),
            $format
        );
    }
    return strftime($format, $ts);
}

I'm sure would help you save time looking for all the possible conversion specifiers not supported on Windows. To verify, just check them on strftime's php manual page (http://php.net/manual/en/function.strftime.php) and Microsoft's msdn page (http://msdn.microsoft.com/en-us/library/fe06s4ak.aspx)

Thanks, Ravi

vittala commented 12 years ago

Hi Ravi

Thanks for your update. If you download the latest github code, you should have both the title control working and the correct date formatting on Windows.

Please let me know if it works for you.

Regards Vittal

vittala commented 12 years ago

Hi Ravi

I've just released version 0.5 of the component in the GitHub downloads. This contains both your Windows date fix and the page heading fix. I'd suggest you continue your testing with the new version, as the templates are now slightly different.

Regards Vittal

RaviOnline commented 12 years ago

Hi Vittal,

I've been testing 0.5 for some time now and had to make the following fixes so far:

(1) I was still receiving a lot of

Warning: Invalid CRT parameters detected in C:\httpd-2.2-x64\htdocs\joomla\libraries\joomla\utilities\date.php on line 464

when the blog entries were loaded until I fixed storeBlogEntries() in helper.php at line 210 as

$db->quote( JFactory::getDate( $entry['date'] )->toFormat( '%F %T %Z' ), true ), $db->quote( WordbridgeHelper::wordBridgeStrftime( '%F %T %Z', $entry['date'] ), true ),

(2) Custom Page Heading specified under Page Display Options is still being ignored. All three (entries/entry/category)/tmpl/default.php(s) need the following little fix in componentheading span

$this->escape( $this->blog_title ) ); ?> $this->escape( !$this->params->get( 'page_heading' ) ? $this->blog_title : $this->params->get( 'page_heading' ) ) ); ?>

This is required because say you're adding a blog named Cognidox Thinks to your Joomla site named GitHub with Joomla configured such that all your site page titles are prefixed as GitHub - Page_Title

But, by default WordBridge would set the Page Title to Cognidox Thinks (assuming that's what your Menu Title is as well) and so to conform you would have to set a custom Page Title as GitHub - Cognidox Thinks

But, you would still want your blog header to say just Cognidox Thinks which is what exactly you could use custom Page Heading option for but it's being ignored right now.

(3) I'm getting a feel that the overall turn-around time on the first hit as well as when WordBridge invalidates the cache might have increased as I often ran into

Fatal error: Maximum execution time of 30 seconds exceeded in C:\httpd-2.2-x64\htdocs\joomla\components\com_wordbridge\helpers\helper.php on line 395

but my connection speed was probably slow at these times.

Regards, Ravi

vittala commented 12 years ago

Hi Ravi

I've just checked some changes into the tree that should resolve the three issues you're having with release 0.5.

Regards Vittal