Forums / Setup & design / ezstarrating wint "plain site" type in eZ 4.2

ezstarrating wint "plain site" type in eZ 4.2

Author Message

Pascal France

Monday 19 October 2009 9:38:08 am

Hi,

I'm usin eZP 4.2 with "plain site" type (so ezwebin is not installed) and I trying to install Star Rating...

I dowloaded the ezstarrating extension from here:
http://packages.ez.no/ezpublish/4.2/4.2.0/
and added it from the admin interface.

As ezwebin is not installed, I download the ezjscore_extension.ezpkg package and unpacked it by hand in:
extension/ezjscore/

I activated these 2 extensions, regenerated the autoload array and cleared all caches.
I ran extension/ezstarrating/sql/mysql/mysql.sql to create the tables
I added a new 'rating' datatype to my article class.

jquery-1.3.2.min.js is well loaded.

The rating datatype use well this template:
extension/ezstarrating/design/standard/templates/content/datatype/view/ezsrrating.tpl

But the only thing which is display is 5 white stars and nothing happen when we click (or fly over) them.

Thinks for your help

pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Gaetano Giunta

Monday 19 October 2009 9:46:51 am

You should give your users (presumably anon) the right to vote: in the permission system you will find a permission for that

Principal Consultant International Business
Member of the Community Project Board

Pascal France

Monday 19 October 2009 9:47:48 am

And I added these policies to the anonymous role:

ezjscore call no limitation
ezjscore run no limitation

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Monday 19 October 2009 9:56:05 am

Hi Gaetano,

Sorry, you posted just before my second post.

Well, I tried even with all rights for all modules for the anonymous users. With no success...

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Monday 19 October 2009 10:32:34 am

Hi,

I just isntalled a 4.2 ezwebin test site:
http://linuxorable.fr/ez42webin/index.php/eng/Company/News/How-to-manage-eZ-Publish

I give all rights of the ezjscore module for anonymous users.

But I don't understand: when I fly over the stars I can see the yellow stars. But nothing happens when I click on them. The rate is not saved.

I think there is something I don't understand.

pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Pascal France

Monday 19 October 2009 10:49:15 am

Hi,

I wonder if my trouble is not due to my Linux installation.
But I don't know how to debug this...

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Wednesday 28 October 2009 2:27:26 pm

Did you solve your problem? I am in the situation. I am trying both extensions (ezjscore, ezstarrating) on 4.0.1.

Can you please help me in that.

Cheers,

André R.

Wednesday 28 October 2009 3:09:20 pm

Here is the needed doc piece from a upcoming article about ezjscore that hopefully help:

Installing
For admin, ezwebin 1.4 and ezflow 1.1 design and higher, customizations to page_head_style.tpl and page_head_script.tpl are done automatically so ezcss_load / ezscript_load are used. These calls are required to make the on demand loading with ezcss_require / ezscript_require work.
If you are using standard, plain, base or older versions of ezwebin/ezflow or need to merge your custom changes to these two templates, read on.

Scripts
First, take a look at ezscript_load description above, as stated it load all files that has been passed to ezscript_require prior in the request and optionally prepends file(s) you pass to it. So an good example on change you need to make to your code is to change your [JavaScriptSettings] JavaScriptList template code from something resembling:

{foreach ezini( 'JavaScriptSettings', 'JavaScriptList', 'design.ini' ) as $script}
    <script language="javascript" type="text/javascript" src={concat( 'javascript/', $script )|ezdesign}></script>
{/foreach}

To:

{ezscript_load( ezini( 'JavaScriptSettings', 'JavaScriptList', 'design.ini' ) )}

If you don't use JavaScriptList, then just add a simple {ezscript_load()} call somewhere in the <head> section of your pagelayout.

CSS
First, take a look at ezcss_load description above, as stated it load all files that has been passed to ezcss_require prior in the request and optionally prepends file(s) you pass to it. With css the example is a bit bigger, but it follows the same pattern by changing:

<style type="text/css">
    @import url({"stylesheets/core.css"|ezdesign(no)});
    @import url({"stylesheets/debug.css"|ezdesign(no)});
    @import url({"stylesheets/pagelayout.css"|ezdesign(no)});
    @import url({"stylesheets/content.css"|ezdesign(no)});
    @import url({"stylesheets/websitetoolbar.css"|ezdesign(no)});
    {foreach ezini( 'StylesheetSettings', 'CSSFileList', 'design.ini' ) as $css_file}
    @import url({concat( 'stylesheets/', $css_file )|ezdesign});
    {/foreach}
    @import url({ezini('StylesheetSettings','ClassesCSS','design.ini')|ezroot(no)});
    @import url({ezini('StylesheetSettings','SiteCSS','design.ini')|ezroot(no)});
</style>

To:

{ezcss_load( array( 'core.css',
                    'debug.css',
                    'pagelayout.css',
                    'content.css',
                    'websitetoolbar.css',
                    ezini( 'StylesheetSettings', 'CSSFileList', 'design.ini' )
))}

{* These are not loaded by ezcss_load since they might exist in ~<user path> *}
<style type="text/css">
    @import url({ezini('StylesheetSettings','ClassesCSS','design.ini')|ezroot(no)});
    @import url({ezini('StylesheetSettings','SiteCSS','design.ini')|ezroot(no)});
</style>

If you don't use CSSFileList, then just remove that last line in the ezcss_load() call.

Feedback is very welcome!

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

John Smith

Thursday 29 October 2009 2:08:29 am

Hi Andre,

Thanks for your kind help, Much appreciated.

I have already done the mentioned changes. Most important lines are below in the <head> section.

{include uri='design:page_head_style.tpl'}
{include uri='design:page_head_script.tpl'}

The code in the <head> section is like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="{$site.http_equiv.Content-language|wash}" lang="{$site.http_equiv.Content-language|wash}">
<head>
{def $basket_is_empty   = cond( $current_user.is_logged_in, fetch( shop, basket ).is_empty, 1 )
     $current_node_id   = first_set( $module_result.node_id, 0 )
     $user_hash         = concat( $current_user.role_id_list|implode( ',' ), ',', $current_user.limited_assignment_value_list|implode( ',' ) )
     $user_id           = $current_user.contentobject_id}

{if and( $current_node_id|eq(0), is_set( $module_result.path.0 ) , is_set( $module_result.path[$module_result.path|count|dec].node_id ) )}
    {set $current_node_id = $module_result.path[$module_result.path|count|dec].node_id}
{/if}

{cache-block keys=array( $uri_string, $basket_is_empty, $user_id )}
{def $pagestyle        = 'nosidemenu noextrainfo'
     $locales          = fetch( 'content', 'translation_list' )
     $pagerootdepth    = ezini( 'SiteSettings', 'RootNodeDepth', 'site.ini' )
     $indexpage        = ezini( 'NodeSettings', 'RootNode', 'content.ini' )
     $infobox_count    = 0
     $path_normalized  = ''
     $path_array       = array()
     $pagedesign_class = fetch( 'content', 'class', hash( 'class_id', 'template_look' ) )
     $pagedepth        = $module_result.path|count
     $content_info     = hash()
}

{if $pagedesign_class.object_count|eq( 0 )|not}
    {def $pagedesign = $pagedesign_class.object_list[0]}
{/if}

{if is_set( $module_result.content_info )}
    {set $content_info = $module_result.content_info}
{/if}
{include uri='design:page_head.tpl'}

{* Used for ezscript_load *}
{include uri='design:page_head_style.tpl'}

{* Used for ezcss_load *}
{include uri='design:page_head_script.tpl'}

</head>

When I fly over the stars I can see the yellow stars. But nothing happens when I click on them. When you refresh the page, the rate is saved saying Rating 4/5 (1 votes cast). Hope this makes sense.

What are the other files which are being used if I have to used these extensions with plain layout?

Pascal France

Thursday 29 October 2009 2:21:07 am

Hi,

Yes I solved the problem.

I wrote a doc (in french - sorry ;-) ) that you will find here:
http://luxpopuli.fr/eZ-Publish/Extensions/eZ-Publish-Star-Rating

And you see a demo here:
http://annuecobio.fr/Alpes-Maritimes-06/alimentation/amap

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Thursday 29 October 2009 2:51:59 am

Cheers, no use to me because it is in french and I think it is regarding 4.2.0. I am trying it on 4.0.1.

Extensions are already working on 4.2 as they are now bundled with.

Hope someone else can help.

Pascal France

Thursday 29 October 2009 3:04:05 am

Hi John,

My doc treats the installation of Star Rating with eZ Publish 4.2.0 installed with the plain Type. This means without Webin or eZFlow.
Therefore, it's a "from scrath" installation of Star Rating that I propose.

Sorry for the French. But I think you can identify milestones.
The names of files, folders, templates, etc ... is invariant.

Regards,

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Thursday 29 October 2009 3:13:44 am

Is it possible to quickly translate it into English, It would be very benefical for other people like me.

Much appreciated.

Pascal France

Thursday 29 October 2009 3:39:54 am

Maybe this can help you:

http://translate.google.com/translate?hl=fr&sl=auto&tl=en&u=http://luxpopuli.fr/eZ-Publish/Extensions/eZ-Publish-Star-Rating

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Thursday 29 October 2009 4:53:03 am

cheers man,

Can you please send me the working example URL. I tried below, but cant see what I am looking for:

http://annuecobio.fr/Alpes-Maritimes-06/alimentation/amap

I am stuck on ponit VII where you have written about javascript. It would be a favour if you can describe in bit more detail....

Pascal France

Thursday 29 October 2009 5:39:39 am

Hi John,

I have a doubt: aren't you looking to install the Star Rating extension ?
On the link:
http://annuecobio.fr/Alpes-Maritimes-06/alimentation/amap
we can see it working (5 white stars).

About javascripts:

First, you have to add this line:

{include uri="extension/ezjscore/design/ezwebin/templates/page_head_script.tpl"}

in the header (between <head> and </head> tags) of your pagelaout template.

Second, you must download this javascript:
http://real.us.yimg.com/lib/yui/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js
and place it to the root of the "javascript" folder of your public design:
design/plain_site/javascript/yahoo-dom-event.js

Third, add these 2 lines in the design.ini.append.php override file of your public siteaccess:

[JavaScriptSettings]
JavaScriptList[]=yahoo-dom-event.js

Fourth, clear all caches.

Hope this help you.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Thursday 29 October 2009 7:28:33 am

Cheers bud,

Everthing is working, entries are going into the database... no problem a part from when you click on the stars it does not refresh the page and show the result like "Thank you for rating" . When I manually refresh the page, I can see the vote number updated....

Is there anything which i am missing....

Pascal France

Thursday 29 October 2009 8:21:52 am

The display of the rating is handled by this code block:

{'Rating: %current_rating/5'|i18n('extension/ezstarrating/datatype', '', hash( '%current_rating', concat('<span id="ezsr_average_', $attribute.id, '" class="ezsr-average-rating">', $rating.rounded_average|wash, '</span>') ))}
({'%rating_count votes cast'|i18n('extension/ezstarrating/datatype', '', hash( '%rating_count', concat('<span id="ezsr_total_', $attribute.id, '">', $rating.rating_count|wash, '</span>') ))}) 
<p id="ezsr_just_rated_{$attribute.id}" class="ezsr-just-rated hide">{'Thank you for rating!'|i18n('extension/ezstarrating/datatype', 'When rating')}</p>
<p id="ezsr_has_rated_{$attribute.id}" class="ezsr-has-rated hide">{'You have already rated this page, you can only rate it once!'|i18n('extension/ezstarrating/datatype', 'When rating')}</p>
<p id="ezsr_changed_rating_{$attribute.id}" class="ezsr-changed-rating hide">{'Your rating has been changed, thanks for rating!'|i18n('extension/ezstarrating/datatype', 'When rating')}</p>

of the design/plain_site/templates/content/datatype/view/ezsrrating.tpl template.

And Normally all should work fine.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

John Smith

Thursday 29 October 2009 10:32:06 am

cheers, I apprecitate your help, but now getting frustrated as it is not refreshing the results when you vote or click on the stars.

Pascal France

Thursday 29 October 2009 11:37:43 am

Hi John,

Well. I think the better way is to stand back ! ;-)

So, in a new temporary folder, do a new plain type eZP 4.0.1 installation and try to install the Star Rating extension. It must work. Once it does, come back to you real site to understand what does not work.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish