Jump to content
Sign in to follow this  
mytheory.

[MODIFICATION] Product Comments on Admin Home

Recommended Posts

Hi,

First, I need to point out that I got the idea and bulk of the code from the great Customer Registration/Management module. So credit goes to the developer of that module.

I used this module for one of our older sites... and loved how as soon as I logged in I could view how many pending registrations there were in the queue, instead of having to remember to go the modules tab and then finding the module, etc. I often forgot and would have customer emailing me why their account wasn't activated yet.

Anyways, moving forward, I had the same problem with the Product Comments module. We recently upgraded our main site to PS v.1.4.2.5... after setting up everything and looking through this module I noticed that there were several comments that were waiting admin approval. So I adopted the code from the other module and modified it for this one.

Now you can see how many comments are waiting approval from the Admin Homepage without having to remember or going filter through the modules.

So to make this modification...

You need to add the following code to your /modules/productcomments/productcomments.php file. Add the following to line 600 (or somewhere near the end where the hooks are).

[EDIT: PS automatically removes or changes the code so use the code from the attached txt file instead of the one posted below!! Otherwise, you will get a parse error!]

    
   function hookBackOfficeHome()
   {
       require_once (dirname(__FILE__).'/ProductComment.php');

       global $cookie;

       $allNotApproved = ProductComment::getByValidate();
       $nbComments = sizeof ($allNotApproved);
       $txt = '';
       $txt .= '

'.
           $this->l('Pending Comment Validations').'';
       $txt .= $this->l('Number of comments waiting for validation : ');
       if ($nbComments == 0)    
           $txt .= ''.$this->l('No comments to validate at this time').'';
       else 
           $txt .= ''.$nbComments.'     id_employee)).'&tab_module=front_office_features&module_name=productcomments">'.$this->l('View').'';
       $txt .= '
';
       return $txt;

   }



Then you have to transplant this module into this additional hook. To do so, go to your BO >> Modules tab >> Positions >> Transplant a module. From the first drop down menu select the Product Comments module, and for the second drop down select "Administration panel homepage." SAVE.

Also, this is optional, but I noticed that the new data feed feature of the homepage was showing first, and the hook for this modification was below these tables and graphs. So changed the location of this hook by editing /admin/tabs/AdminHome.php

I moved the following code from line 436 to about line 205. Now this is the first thing that shows at the very top with everything else following below it.

echo Module::hookExec('backOfficeHome');



Hope somebody finds this useful!

  • Like 1

Share this post


Link to post
Share on other sites

same error here. using PS 1.4.

This modification would be really great!! any help is appreciated!

Share this post


Link to post
Share on other sites

Hi,

I will try and take a look at this as soon as I have time. I have it working on a 1.4.1 and 1.4.2.5 site so just going off a limb, do you still get the error if you leave the second part of the code in its original place?

The code below...

echo Module::hookExec('backOfficeHome');



I moved it so it can show at the very top instead of the bottom below all the other graphs and data. When I was first moving this around I got some errors because it was not in the correct block of code.

I would advise at least for testing purposes, just adding the long bit of code and leaving the hook as is. Let me know if this removes the error.

If not I will take a look at the long bit of code to make sure it is correct.

HTH!

Share this post


Link to post
Share on other sites

when I add the code to /modules/productcomments/productcomments.php file I get the error in BO whenever I go in the modules tab. and probably because of this the module cannot be transplanted to Admin home panel

Share this post


Link to post
Share on other sites

Hi,

So I tried the original code from this post and for some reason I'm getting the same error. So I copied and pasted the code from my files which work... here you go again.

   function hookBackOfficeHome()
   {
       require_once (dirname(__FILE__).'/ProductComment.php');

       global $cookie;

       $allNotApproved = ProductComment::getByValidate();
       $nbComments = sizeof ($allNotApproved);
       $txt = '';
       $txt .= '

'.
           $this->l('Pending Comment Validations').'';
       $txt .= $this->l('Number of comments waiting for validation : ');
       if ($nbComments == 0)    
           $txt .= ''.$this->l('No comments to validate at this time').'';
       else 
           $txt .= ''.$nbComments.'     id_employee)).'&tab_module=front_office_features&module_name=productcomments">'.$this->l('View').'';
       $txt .= '
';
       return $txt;

   }



Sorry for the confusion!

Share this post


Link to post
Share on other sites

Ok... so this forum is automatically removing parts of the code or converting it... anyways the right code does not get saved when I submit a reply. So I have attached a text file with the block of code exactly as it should be.

PLEASE IGNORE THE CODES FROM THE ABOVE POSTS... USE THE ONE FROM THE TXT FILE.

Let me know if this works or not.

Thanks!

ProductComments.txt

Share this post


Link to post
Share on other sites

yes it's working now! thank you

please be aware that on PS 1.4 the file Adminhome.php is located under the folder TABS in your admin folder.

Share this post


Link to post
Share on other sites

Glad it is working now!

And yes you are correct... the AdminHome.php file is not in the /classes/ folder rather it is in this path: /admin/tabs/AdminHome.php

Thanks for correction... I have edited the my first post.

Share this post


Link to post
Share on other sites

Implemented on PS 1.4.8.2 and works fine !

Very usefull mod, thanks for making me save much time ;)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More