push corner
  • Gear Reviews

  • Reviews of hardware and 
  • software used by us at
    FreelanceSoundlabs
 news icon
  • Latest News

    Find out the latest about the site and new products and projects.
 NKS VST Libraries for Komplete/Maschine
  • NKS VST Libraries for Komplete/Maschine

  • Get NKS browser libraries for your Komplete/Maschine

K2 Page Break Fixes

Another "note to self" which may prove useful to other Joomla user using the K2 comment system.

Joomla contains a simple "Page Break" module that allows pages to be created in an item. Basically a single item can have breaks inserted which create a new page with the option to have a table list or just <> buttons. K2 seems to have some issues with this and does not recognise the default pagebreak function in articles.

A solution for this (which also works in other article management systems) is a plugin called PageBreakMyJSpace

This replaces the default page break feature with a new plugin that contains a lot more custom options for managing how the system works, custom layout of the table of contents and a heap of other neat features. It also takes the default page break button and references within Joomla editors and uses these to work with the plugin so it's almost plug-&-play.

There is however a few things to be aware of:

- You need to disable the default Joomla page break plugin.
- It requires the Cache system to be OFF

In regards to the cache system this refers to the global site cache which if switched ON the pages never allow you to navigate further than page 1 (clicking Next will return to page 1). When I disabled the cache system my website host advised my site was consuming far too much CPU. So what may be required is to allow global cache for the site but disable cache for pages that use the Page Break plugin. On the developers site they also have listed a plugin that achieves just this: k2nocachepagebreak

Simply install this plugin and enable it and any pages that contain a page break will not be cached by the system allowing the plugin to work correctly. Simple fix.

Login Issues & Fixes!

This is more of a "note to self" should I have this issue again.

When I first designeed the site I tested the user registration system and it worked just fine but this was before I added the K2 content manager and also before the latest version of reCaptcha. Up until now I really have had no need for user logins but now I have some special donor features available for downloading files upon donations I needed to implement a user management system for downloads and this is where I discovered the user registration system was busted. 

The issue was that I updated to the new "1 click - i'm not a robot" Captcha protection which is evident on contact forms and throughout the site but when I visited the registration page the old captcha element was displayed and I had no idea why this was. The issue was that when I entered in the result it would always fail with either "empty result" or "wrong text" 

After hours or testing and googling I finally tracked down the issue to be the fact K2 was enabled to allow user registrations and within K2 there is a separate captcha setup. All that was needed was to simply disable the use of the K2 captcha which then allowed the global captcha to be used. 

The joys of managing a friggin website!

Joomla K2 Comment Notification Hack

The website content (articles, categories, comments etc) are all part of the "K2" system installed on the site. This is an "advanced" article management system that adds a heap of extra features over the standard way Joomla manages articles on the site. All the lists and layout for the articles you read (including this one) are managed by this Joomla component. 

As with most things when designing a website, there is not a "1 solution fits all" and there have been some problems to overcome which is why it takes sooooo long to get everything going. 

The Issue

One issue I discovered about this K2 system is the comment feature at the end of articles which allow visitors to leave their comments does not notify the web administrator (me) of new comments. This seems strange to me since most other comment systems I have tested have this as a basic feature.

Jcomments for instance has not only this feature but also the ability to delete comments or edit them directly from the email sent which means if someone posts a spam or offensive comment it can be removed in minutes just using my phone.

I wanted the integrated feature of the K2 comment system and simply wanted to know if a user has posted comments to an article and know the contents of what they posted. It appeared the only "plugin" solution would cost $20 and considering the K2 framework component was free it seemed a bit of a ripoff for a single simple feature.

The Hack Fix

I spent some time researching solutions and came over a posted hack that allowed a notification to be sent if you had comments NOT set to auto-publish. I wanted user comments to publish automatically so after some messing around I managed to create a simple solution that will send the following email:

 


 

 From Freelance Soundlabs

To This email address is being protected from spambots. You need JavaScript enabled to view it.
Date Today 10:54
Priority Normal


New User Comment Posted:
Name: test
Email: This email address is being protected from spambots. You need JavaScript enabled to view it.
Website: www.testwebsite.com
comment: This is a test comment with some words that say things to make up the volume of the message body so there is something in the damn message!!!

 


 

This will be sent whenever someone publishes a comment and has all the info to decide if it is a genuine comment or spam to be actioned. The email it is sent too is the email set in the K2 parameters for the Comment Reporting email where users can report comments to the admin. 

This hack requires editing a file and will require this edit to be redone if the component is updated so it is not a perfect solution but a workable one. To apply it to your site follow these steps:

1. Open the file: components/com_k2/models/item.php
2. Search in the file for the line that contains: K2_COMMENT_ADDED_REFRESHING_PAGE
3. Directly above that line paste the following chunk of code:

$mainframe = &JFactory::getApplication();
$mail = &JFactory::getMailer();
$senderEmail = $mainframe->getCfg('mailfrom');
$senderName = $mainframe->getCfg('fromname');
$mail->setSender(array($senderEmail, $senderName));
$mail->setSubject(JText::_('K2_NEW_COMMENT'));
$mail->IsHTML(true);
$body = "
".JText::_('New User Comment Posted').":

".JText::_('K2_NAME').": ".$userName."

".JText::_('K2_EMAIL').": ".$commentEmail."

".JText::_('K2_WEBSITE').": ".$commentURL."

".JText::_('K2_COMMENT').": ".nl2br($row->commentText)."
";
$mail->setBody($body);
$mail->ClearAddresses();
$mail->AddAddress($params->get('commentsReportRecipient', $mainframe->getCfg('mailfrom')));
$mail->Send();


Make sure you have an email set in the K2 parameters/comments section for comment reports.

Test by posting a new comment and you should receive an email. 

If you want to set an email for comments to be "approved" then do exactly the same as above but search for the code: K2_COMMENT_ADDED_AND_WAITING_FOR_APPROVAL

The only extra information I would love to include in the message would be the article the comment was posted too. I am not an expert in this stuff so I am not sure but maybe a Joomla expert will help me out one day. For now, this works just fine.

 

 

 

Go to top