Hello,
I don't know if you will be able to use them because I don't use the modules/blocks you are speaking of but here are 2 pnRender plugins that I have done for another module (books) when I did the pnRendered version.
First one is a plugin to display the ratings for an item using exactly the same style (stars, ...) as the Ratings module.
<?php/**
*
* Type: Function
* Author: Jean-Michel Védrine (vedrine _AT_ vedrine _DOT_ net)
*
* Display the Ratings for an item
*@param params['modname'] string module's name
*@param params['objectid'] string item ID
*@param params['style'] style
*@return string processed smarty output
*/function smarty_function_rating
($params, &
$smarty){ extract($params);
unset($params);
if (!pnModAvailable
('Ratings') || !pnModIsHooked
('Ratings',
$modname)) { return;
} if (!
isset($objectid)) { return;
} if (!
isset($style)) { $style = pnModGetVar
('Ratings',
'defaultstyle');
} // security check // check if the user is allowed to the any ratings for this module/style/objectid if (!pnSecAuthAction
(0,
'Ratings::',
"$modname:$style:$objectid", ACCESS_READ
)) { return;
} if (!pnModAPILoad
('Ratings',
'user')) { return;
} $rating = pnModAPIFunc
('Ratings',
'user',
'get',
array('modname' =>
$modname,
'objectid' =>
$objectid));
if (!
isset($rating)) { return;
} // language $lang = pnVarPrepForOS
(pnUserGetLang
());
// theme directory $theme = pnVarPrepForOS
(pnUserGetTheme
());
$modname =
'Ratings';
$osmodname = pnVarPrepForOS
($modname);
$cWhereIsPerso = WHERE_IS_PERSO;
if (!
(empty($cWhereIsPerso))) { $themelangpath =
$cWhereIsPerso .
"themes/$theme/templates/modules/$osmodname/images/$lang";
$themepath =
$cWhereIsPerso .
"themes/$theme/templates/modules/$osmodname/images";
$corethemepath =
$cWhereIsPerso .
"themes/$theme/images";
} else { $themelangpath =
"themes/$theme/templates/modules/$osmodname/images/$lang";
$themepath =
"themes/$theme/templates/modules/$osmodname/images";
$corethemepath =
"themes/$theme/images";
} // module directory $modinfo = pnModGetInfo
(pnModGetIDFromName
($modname));
$osmoddir = pnVarPrepForOS
($modinfo['directory']);
if ($modinfo['type'] !=
1) { $modlangpath =
"modules/$osmoddir/pnimages/$lang";
$modpath =
"modules/$osmoddir/pnimages";
$syslangpath =
"system/$osmoddir/pnimages/$lang";
$syspath =
"system/$osmoddir/pnimages";
} else { $modlangpath =
"modules/$osmoddir/images/$lang";
$modpath =
"modules/$osmoddir/images";
$syslangpath =
"system/$osmoddir/images/$lang";
$syspath =
"system/$osmoddir/images";
} $name1 = pnVarPrepForOS
('star.gif');
$name2 = pnVarPrepForOS
('halfstar.gif');
// search for the images $imgsrc1 =
'';
$imgsrc2 =
'';
foreach (array($themelangpath,
$themepath,
$corethemepath,
$modlangpath,
$modpath,
$syslangpath,
$syspath) as $path) { if (file_exists("$path/$name1") &&
is_readable("$path/$name1") &&
file_exists("$path/$name2") &&
is_readable("$path/$name2")) { $imgsrc1 =
"$path/$name1";
$imgsrc2 =
"$path/$name2";
break;
} } if ($imgsrc1 ==
'') { $smarty->
trigger_error("pnrender plugin rating: images not found");
return;
} switch($style) { case 'percentage':
$output =
"$rating%";
break;
case 'outoffive':
$rating =
(int
)(($rating+10)/
20);
$output=
"$rating/5";
break;
case 'outoffivestars':
$output =
'';
$rating =
(int
)($rating/
2);
$intrating =
(int
)($rating/
10);
$fracrating =
$rating -
(10*
$intrating);
for ($i=
1;
$i<=
$intrating;
$i++
){ $output .=
'<img src="' .
$imgsrc1 .
'" alt="" />';
} if ($fracrating >=
5) { $output .=
'<img src="' .
$imgsrc2 .
'" alt="" />';
} break;
case 'outoften':
$rating =
(int
)(($rating+5)/
10);
$output=
"$rating/10";
break;
case 'outoftenstars':
$output =
'';
$intrating =
(int
)($rating/
10);
$fracrating =
$rating -
(10*
$intrating);
for ($i=
1;
$i<=
$intrating;
$i++
){ $output .=
'<img src="' .
$imgsrc1 .
'" alt="" />';
} if ($fracrating >=
5) { $output .=
'<img src="' .
$imgsrc2 .
'" alt="" />';
} break;
} if (isset($assign)) $smarty->
assign($assign,
$output);
else return $output;
}?>
save in a function.rating.php file either in modules/your_module/pntemplates/plugins/ or in modules/pnRender/plugins
usage
Where you want the rating to appear, add in your template
Where module_name is the name of the module the rated item belongs to and item_id is the rated item id
And for the number of
EZComments :
<?php/**
*
* Type: Function
* Author: Jean-Michel Védrine (vedrine _AT_ vedrine _DOT_ net)
*
* Display the number of EZComments for an item
*@param params['modname'] string module's name
*@param params['objectid'] string item ID
*@return string processed smarty output
*/function smarty_function_ezcommentscount
($params, &
$smarty){ if (!pnModAvailable
('EZComments')) { return;
} extract($params);
unset($params);
if (!
isset($objectid) || !
isset($modname)) { return;
} if (isset($status)) { $comments = pnModAPIFunc
('EZComments',
'user',
'countitems',
array('mod' =>
$modname,
'objectid' =>
$objectid,
'status' =>
$status));
} else { $comments = pnModAPIFunc
('EZComments',
'user',
'countitems',
array('mod' =>
$modname,
'objectid' =>
$objectid));
} if (isset($assign)) $smarty->
assign($assign,
$comments);
else return $comments;
}?>
of but here are 2 pnRender plugins that I have done for another module (books) when I did the pnRendered version.
First one is a plugin to display the ratings for an item using exactly the same style (stars, ...) as the Ratings module.
<?php/**
*
* Type: Function
* Author: Jean-Michel Védrine (vedrine _AT_ vedrine _DOT_ net)
*
* Display the Ratings for an item
*@param params['modname'] string module's name
*@param params['objectid'] string item ID
*@param params['style'] style
*@return string processed smarty output
*/function smarty_function_rating
($params, &
$smarty){ extract($params);
unset($params);
if (!pnModAvailable
('Ratings') || !pnModIsHooked
('Ratings',
$modname)) { return;
} if (!
isset($objectid)) { return;
} if (!
isset($style)) { $style = pnModGetVar
('Ratings',
'defaultstyle');
} // security check // check if the user is allowed to the any ratings for this module/style/objectid if (!pnSecAuthAction
(0,
'Ratings::',
"$modname:$style:$objectid", ACCESS_READ
)) { return;
} if (!pnModAPILoad
('Ratings',
'user')) { return;
} $rating = pnModAPIFunc
('Ratings',
'user',
'get',
array('modname' =>
$modname,
'objectid' =>
$objectid));
if (!
isset($rating)) { return;
} // language $lang = pnVarPrepForOS
(pnUserGetLang
());
// theme directory $theme = pnVarPrepForOS
(pnUserGetTheme
());
$modname =
'Ratings';
$osmodname = pnVarPrepForOS
($modname);
$cWhereIsPerso = WHERE_IS_PERSO;
if (!
(empty($cWhereIsPerso))) { $themelangpath =
$cWhereIsPerso .
"themes/$theme/templates/modules/$osmodname/images/$lang";
$themepath =
$cWhereIsPerso .
"themes/$theme/templates/modules/$osmodname/images";
$corethemepath =
$cWhereIsPerso .
"themes/$theme/images";
} else { $themelangpath =
"themes/$theme/templates/modules/$osmodname/images/$lang";
$themepath =
"themes/$theme/templates/modules/$osmodname/images";
$corethemepath =
"themes/$theme/images";
} // module directory $modinfo = pnModGetInfo
(pnModGetIDFromName
($modname));
$osmoddir = pnVarPrepForOS
($modinfo['directory']);
if ($modinfo['type'] !=
1) { $modlangpath =
"modules/$osmoddir/pnimages/$lang";
$modpath =
"modules/$osmoddir/pnimages";
$syslangpath =
"system/$osmoddir/pnimages/$lang";
$syspath =
"system/$osmoddir/pnimages";
} else { $modlangpath =
"modules/$osmoddir/images/$lang";
$modpath =
"modules/$osmoddir/images";
$syslangpath =
"system/$osmoddir/images/$lang";
$syspath =
"system/$osmoddir/images";
} $name1 = pnVarPrepForOS
('star.gif');
$name2 = pnVarPrepForOS
('halfstar.gif');
// search for the images $imgsrc1 =
'';
$imgsrc2 =
'';
foreach (array($themelangpath,
$themepath,
$corethemepath,
$modlangpath,
$modpath,
$syslangpath,
$syspath) as $path) { if (file_exists("$path/$name1") &&
is_readable("$path/$name1") &&
file_exists("$path/$name2") &&
is_readable("$path/$name2")) { $imgsrc1 =
"$path/$name1";
$imgsrc2 =
"$path/$name2";
break;
} } if ($imgsrc1 ==
'') { $smarty->
trigger_error("pnrender plugin rating: images not found");
return;
} switch($style) { case 'percentage':
$output =
"$rating%";
break;
case 'outoffive':
$rating =
(int
)(($rating+10)/
20);
$output=
"$rating/5";
break;
case 'outoffivestars':
$output =
'';
$rating =
(int
)($rating/
2);
$intrating =
(int
)($rating/
10);
$fracrating =
$rating -
(10*
$intrating);
for ($i=
1;
$i<=
$intrating;
$i++
){ $output .=
'<img src="' .
$imgsrc1 .
'" alt="" />';
} if ($fracrating >=
5) { $output .=
'<img src="' .
$imgsrc2 .
'" alt="" />';
} break;
case 'outoften':
$rating =
(int
)(($rating+5)/
10);
$output=
"$rating/10";
break;
case 'outoftenstars':
$output =
'';
$intrating =
(int
)($rating/
10);
$fracrating =
$rating -
(10*
$intrating);
for ($i=
1;
$i<=
$intrating;
$i++
){ $output .=
'<img src="' .
$imgsrc1 .
'" alt="" />';
} if ($fracrating >=
5) { $output .=
'<img src="' .
$imgsrc2 .
'" alt="" />';
} break;
} if (isset($assign)) $smarty->
assign($assign,
$output);
else return $output;
}?>
save in a function.ezcommentscount.php file either in modules/your_module/pntemplates/plugins/ or in modules/pnRender/plugins
usage
Where you want the number of comments to appear, add in your template
Where module_name is the name of the module the commented item belongs to and item_id is the commented item id.
Hope this help.
Please note ezcommentscount plugin is a modified version of the one Jörn did for his
Pagesetter module.
edited by: jmvedrine, Jan 29, 2008 - 09:27 AM
--
Visit my
live reef aquarium.
My Amazon wish list.