I am working on a website where one of the sections gets a menu item leading to a blog view which is intended as an actual blog. So, instead of intro's, this blog view will contain a few fuill length articles. Of course it would be nice to have voting there. However, the way things work in Joomla, making a real blogging page is not easy, and for example the voting display of the core rating plugin is blocked for blog views. By the way, the front page is a blog view like the section and category blogs. Since VOTItaly is modelled somewhat on the core rating plugin, it has the same issue of hiding (zero vote) ratings in blog views.
To solve this, I have hacked the VOTItaly plugin, and here is how it is done.
The key problem is in this line:
| Code: |
if (isset($row->rating_count) && $params->get( 'show_vote' ) && !$params->get( 'popup' )) {/
|
More specifically, if you remove isset($row->rating_count) from this line, it will always work in blog views. You could stop there, but I could not because I wanted to show the ratings only in the blog view of one section or category.
So, I made some options in the xml file, as follows:
| Code: |
<param name="do_frontpage" type="radio" default="0"
label="Show (zero) ratings in the front page blog view" description="
Show ratings in the front page blog view, even zero ratings.">
<option value="1">VOTITALY_YES</option>
<option value="0">VOTITALY_NO</option>
</param>
<param name="do_secblogs" type="radio" default="0"
label="Show (zero) ratings in section blog views" description="
Show ratings in all or selected section blog views, even zero ratings.
Fill in the list of sections if you select option 'List'.">
<option value="1">VOTITALY_YES</option>
<option value="0">VOTITALY_NO</option>
<option value="2">List</option>
</param>
<param name="listed_secs" type="text" default="" label="
List of sections" description="List of sections where (zero) ratings
should be shown." />
<param name="do_catblogs" type="radio" default="0" label="
Show (zero) ratings in category blog views" description="Show ratings
in all or selected category blog views, even zero ratings. Fill in the list
of categories if you select option 'List'.">
<option value="1">VOTITALY_YES</option>
<option value="0">VOTITALY_NO</option>
<option value="2">List</option>
</param>
<param name="listed_cats" type="text" default="" label="List of
categories" description="List of categories where (zero) ratings
should be shown." />
|
Then, I replaced the above quoted line of php by the following code:
| Code: |
/*** begin: making rating in blogs possible ***/
$content = ( JRequest::getCmd( 'option' ) == 'com_content' ) ? true : false;
$frontpage = ( JRequest::getCmd( 'view' ) == 'frontpage' ) ? true : false;
$section = ( JRequest::getCmd( 'view' ) == 'section' ) ? true : false;
$category = ( JRequest::getCmd( 'view' ) == 'category' ) ? true : false;
$blog = ( JRequest::getCmd( 'layout' ) == 'blog' ) ? true : false;
$request_id = JRequest::getInt( 'id' );
$do_frontpage = $plgParams->get('do_frontpage', 0);//0 is no 1 is yes
$do_secblogs = $plgParams->get('do_secblogs', 0);//0 is no 1 is yes 2 is list
$listed_secs = $plgParams->get('listed_secs', '');
$do_catblogs = $plgParams->get('do_catblogs', 0);//0 is no 1 is yes 2 is list
$listed_cats = $plgParams->get('listed_cats', '');
$sec_listed = false;
$cat_listed = false;
if ( $content && $blog ) {
if ( $do_secblogs == 1 ) {
$sec_listed = true;
}
if ( $do_catblogs == 1 ) {
$cat_listed = true;
}
if ( $section && ( !empty($listed_secs) && $do_secblogs == 2 ) ) {
$listed_secn = explode(",",$listed_secs);
foreach ($listed_secn as $secn) {
if ($request_id == $secn) {
$sec_listed = true;
}
}
}
if ( $category && ( !empty($listed_cats) && $do_catblogs == 2 ) ) {
$listed_catn = explode(",",$listed_cats);
foreach ($listed_catn as $catn) {
if ($request_id == $catn) {
$cat_listed = true;
}
}
}
}
if ( ( $frontpage && $do_frontpage ) || ( $section && $sec_listed ) || ( $category && $cat_listed ) ) {
$check_rating_count = true;
} else {
$check_rating_count = (isset($row->rating_count)) ? true : false;
}
if ( $check_rating_count && $params->get( 'show_vote' ) && !$params->get( 'popup' ) ) {
//if (isset($row->rating_count) && $params->get( 'show_vote' ) && !$params->get( 'popup' )) {//original line
/*** end: making rating in blogs possible ***/
|
Then I uploaded the modified files and went into the plugin settings, where I set the new option 'Show (zero) ratings in section blog views' to 'List' and then filled in my section number '9' into the new field 'List of sections'. And, voilĂ , it all seems to work as I wanted and expected.
Perhaps someone feels like changing this code to also allow for listed sections to be excluded instead of included. And then, perhaps this would be a nice improvement for the next version?