Jump to content

[MODULE][FREE] WordPress Bridge


leeburridge
 Share

Recommended Posts

** UPDATED - Version 1.1 now attached **

This is my first PrestaShop module. Only took a few hours and I'm quite pleased with it.

Basically this will allow you to incorporate WordPress posts into your PrestaShop in the easiest possible way. Screenshots are attached of what it looks like. Please enjoy and if you use and like this module why not donate using PayPal to lee@leeandgrace.co.uk to keep me making new modules smile.png

Installation

  • Install WordPress and configure - Store the tables in the same database as PrestaShop
  • Upload the attached .ZIP file
  • Configure the Module
  • Transplant the module

Documentation
There are only a few options that you can set in the Configure section :

Module Display Title
This is what is shown at the top of your module eg. Latest News or Blog Posts etc.

WordPress Posts Table
Specify the name of the table that contains your WordPress posts. By default WordPress installs to wp_posts however you can change the prefix from wp when installing.

Qty
Number of posts to display.

CMS ID
The ID number of the CMS page you want to appear at the header of this module

CMS Class
DIV Class for the header

WordPress Class
DIV class for the WordPress segment

CMS Footer ID
The ID number of the CMS page you want to appear at the foot of this module

CMS Footer Class
DIV Class for the footer

Prerequisites
PrestaShop 1.4.x
WordPress

If anyone has any issues or has any feature requests post here smile.png

ChangeLog
v1.1

  • Added some CMS integration for header and footer which will remain static
  • Added class settings for CMS header and footer

v1.0

  • First iteration

Database Changes
Adds 3 fields to Configuration :
PS_WPBTITLE
PS_WPBTABLE
PS_WPBQTY
PS_WPBCMSID
PS_WPBCMSCLASS
PS_WPBWPCLASS
PS_WPBCMSFOOTCLASS
PS_WPBCMSFOOTID

You can get the files from Github here : https://github.com/leeburridge/modwordpress

post-269786-0-73477900-1317898814_thumb.png

modwordpress.zip

post-269786-0-61492300-1317925625_thumb.png

Edited by leeburridge (see edit history)
  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Nice work ! something really needed for presta !

 

Can it be placed in CMS page ? I think this will be the main usage, since shop owners will just need to create cms page called "blog"

I'm seriosly considering donating if it really does the job :)

 

Is it possible to use this module, without having the actual worpress working alone where it is installed ? I guess it will be installed in yourdomain.com/blog, so when you go to that adress will it load the wordpress alone? I'll want to see any wordpress content only through your module, so it will be something like a news module.

 

or maybe the idea is to have separated blog for your shop, and just show articles from in in the wordpress install, and when you click on them to go to the blog ?

Share this post


Link to post
Share on other sites

Hi, thanks for the reply. I haven't looked at placing it on a CMS page yet. Mine is placed on the front page of my store which you can hook into without any problems. I'll test the CMS stuff and get back to you.

 

You need a working WordPress install for this to work - by that I mean that you would have a /wordpress folder or /blog or whatever however there is nothing stopping you from removing the main WordPress display pages so you only get a back end to it. I think you can remove the files from the root of your WordPress installation to do this but I would test it first ;) Essentially I am using only the backend of WordPress in order to quickly create news articles on my site which I think is what you are wanting.

Share this post


Link to post
Share on other sites

Thanks, works well.

 

Can you include an option to display only blog posts and not pages please?

 

Also what are the CMS header and footer settings for?

 

Will definately be donating, cheers

Share this post


Link to post
Share on other sites

Installation

  • Install WordPress and configure - Store the tables in the same database as PrestaShop
  • Upload the attached .ZIP file
  • Configure the Module
  • Transplant the module

Hi,

I have problem.

I've:

- installed fresh wordpress

- uploaded and installed your module

- used the default configuration of yoru module

 

Where can I see in Prestashop a Wordpress content? I can't see anything new at Prestashop homepage.

 

Thanks,

Radek

Share this post


Link to post
Share on other sites

Hi leeburridge,

Nice work. Thanks.

I made a few modifications of your module.

 

1) Module shows beside wordpress post also wordpress pages. I want to show wordpress post only (without pages). Modification:

change in modwordpress.php this:

$sql = "SELECT * FROM ".$wpbtable." where `post_status`='publish' ORDER BY ID DESC";

to this:

$sql = "SELECT * FROM ".$wpbtable." where `post_status`='publish' AND `post_type`='post' ORDER BY ID DESC";

 

2) If is in wordpress saved only eg: 2 posts and you have configured in this module "Qty" to higher number than 2 (eg: 5), then you got in this case 3 empty headings in Prestashop.

Fix in modwordpress.php:

add after:

  foreach($_cms as $cms)
 {
  $news[$i] = $cms['post_title'];
  $ndata[$i] = $cms['post_content'];
  $pdate[$i] = date("d.m.Y", strtotime($cms['post_date']));
  $i++;
 }

this code at new line:

$wpbqty = (Db::getInstance()->Affected_Rows() < $wpbqty) ? Db::getInstance()->Affected_Rows() : $wpbqty;

 

Cheers,

Radek

  • Like 1

Share this post


Link to post
Share on other sites

Hi,

1/ I install Prestashop 1.4.5.1 on localhost.

2/ Wordpress is already installed.

3/ Install module modwordpress OK

4/ hook module on the home page OK

 

What did you mean by:

Install WordPress and configure - Store the tables in the same database as PrestaShop

 

I have 2 database:

1 for Presta, 1 for WP

 

I must re-install WP with the table wp_posts ? I don't really understand, can you explain me.

Thank you

Share this post


Link to post
Share on other sites

Very nice plugin.

It works like a charm.

I just want to know if it is possible to have an excerpt with a "read more" button instead of all the post text without using a Wordpress plugin because I only want to show the excerpt on my Prestashop Homepage.

Thanks.

 

 

@Graphileom :

Il faut que ce soit la même base de données pour Prestashop et Wordpress car si tu regardes bien le module, il ne fait pas appel à une base de données externe pour l'import des posts de Wordpress.

Ça utilise les paramètres de connexion du settings.inc.php de Prestashop au final.

Il faut que Wordpress soit installé sur la même base que Prestashop si tu veux que le module communique avec Wordpress donc il te faut une base avec tes tables ps_ et tes tables wp_ dedans.

Share this post


Link to post
Share on other sites

OK compris merci.

 

Very nice plugin.

It works like a charm.

I just want to know if it is possible to have an excerpt with a "read more" button instead of all the post text without using a Wordpress plugin because I only want to show the excerpt on my Prestashop Homepage.

Thanks.

 

 

@Graphileom :

Il faut que ce soit la même base de données pour Prestashop et Wordpress car si tu regardes bien le module, il ne fait pas appel à une base de données externe pour l'import des posts de Wordpress.

Ça utilise les paramètres de connexion du settings.inc.php de Prestashop au final.

Il faut que Wordpress soit installé sur la même base que Prestashop si tu veux que le module communique avec Wordpress donc il te faut une base avec tes tables ps_ et tes tables wp_ dedans.

Share this post


Link to post
Share on other sites

I just want to know if it is possible to have an excerpt with a "read more" button instead of all the post text without using a Wordpress plugin because I only want to show the excerpt on my Prestashop Homepage.

 

 

Modify $ndata[$i] = $cms['post_content']; by $ndata[$i] = $cms['post_excerpt]; in modwordpress.php

You have to write manually an excerpt or use a wordpress plugin to show the excerpt on Prestashop.

 

--OR--

 

Modify {$ndata[$i++]} by {$ndata[$i++]|truncate:128:'...'} in modwordpress.tpl

You can choose the truncate value you want... I use this solution.

 

Sorry for my bad english :)

Share this post


Link to post
Share on other sites

  • 3 weeks later...

It's a nice module.

 

I just want to know if the Module Display Title can be in multilingual....as I see in the source code that it can be but there's not exist in the Translation tab in BO.

 

Thanks a lot.

Share this post


Link to post
Share on other sites

Hi, Im not much of a coder, but I managed to add a 'Read full story...' link to each blog entry. What I did first was what deuxplustrois suggested and truncated the size of each post to 428 characters(perfect for my layout).

 

Then in modwordpress.php I changed

 

$_cms = Db::getInstance()->ExecuteS($sql);
       $i=0;
       foreach($_cms as $cms)
       {
           $news[$i] = $cms['post_title'];
           $ndata[$i] = $cms['post_content'];
           $pdate[$i] = date("d/m/Y", strtotime($cms['post_date']));
           $i++;
           }

 

to

 

$_cms = Db::getInstance()->ExecuteS($sql);
       $i=0;
       foreach($_cms as $cms)
       {
           $news[$i] = $cms['post_title'];
           $ndata[$i] = $cms['post_content'];
           $pdate[$i] = date("d/m/Y", strtotime($cms['post_date']));
           $id[$i] = $cms['ID'];
           $i++;
           }

 

Then further down the page where it has all the smarty variables($smarty->assign('news', $news); etc)

I added:

 

$smarty->assign('id', $id);

 

Then I opened up modwordpress.tpl and changed:

 

<div id="wordpress_content" class="{$wpbwpclass}">
       <hr>
       <h1>{l s={$wpbtitle} mod='modwordpress'}</h1>
       {$i=0}
       {foreach from=$count item=product name=product}
          	 <h4 class="greydark">{$pdate[$i]} - {$news[$i]}</h4>
<P ALIGN="right">
               {$ndata[$i++]|truncate:428:'...'}
</P>

 

to

 

<div id="wordpress_content" class="{$wpbwpclass}">
       <hr>
       <h1>{l s={$wpbtitle} mod='modwordpress'}</h1>



       {$i=0}
       {foreach from=$count item=product name=product}
               <a href="lab/archives/{$num[$i]}"><h4 class="greydark">{$pdate[$i]} - {$news[$i]}</h4></a>
<P ALIGN="right"><a href="lab/archives/{$num[$i]}">Read full story...</a></p><br>
               {$ndata[$i++]|truncate:428:'...'}

</P>

 

you will need to change /lab/archives to your installation folder. Im not sure if this will work for others but its working just fine on my server. And sorry for the messy way of doing things, like I said, Im not a coder :)

Share this post


Link to post
Share on other sites

@Bhasha: from what I understood, you changed Prestashop code and are saying that you don't need a module with this solution. Well, that's the point of having modules: you can leave Prestashop unchanged (which also means you can upgrade etc.).

Share this post


Link to post
Share on other sites

Hello everybody,

 

I have been playing with this module.

I tried to add the possibility to have a separate databse for Prestashop and WordPress

Can someone review my code because, I have a few problem's

 

sincerely,

 

update: I found my error !! It works but it needs some tweaks I think ....

modwordpress.zip

Share this post


Link to post
Share on other sites

  • 1 month later...

Hello everybody,

 

I have been playing with this module.

I tried to add the possibility to have a separate databse for Prestashop and WordPress

Can someone review my code because, I have a few problem's

 

sincerely,

 

update: I found my error !! It works but it needs some tweaks I think ....

 

Hi neastea,

 

did you manage to get the two databases working?

I'm a little bit cautious with my Prestashop database so I would also like to use a separate Wordpress database.

Very interesting so could you please let me know?

 

cheers

-Dave

Share this post


Link to post
Share on other sites

  • 4 months later...

Hello everybody,

 

I have been playing with this module.

I tried to add the possibility to have a separate databse for Prestashop and WordPress

Can someone review my code because, I have a few problem's

 

sincerely,

 

update: I found my error !! It works but it needs some tweaks I think ....

I'd like to include my wp-blog on my site but not in the same database and am happy you are trying with these modules, thank you! If I'd get them working I'd be happy to donate.

 

I keep getting the error "The database selection cannot be made", so I guess the settings are incorrect. But I checked with the Wordpress installation and set base to "wp_" and table to "wp_posts". I tried many different configurations but can't get this working. Any ideas?

Share this post


Link to post
Share on other sites

  • 4 months later...

I just successfully installed this on a 1.5 installation of prestashop (and with wordpress 3.4.2). No problem - works perfekt. I did some small modifications to have it exclude pages from the loop and put permalinks and excerpts instead of full post-content. If anybody want the slightly modified version I put it on my bitbucket - https://bitbucket.org/Viktor89/modwordpress . Anyway, gotta give thanks to the author for this - couldn't have figured it out myself (and I tried).

Share this post


Link to post
Share on other sites

  • 2 months later...

hi,

i installed the plugin on 1.5.3.1 prestashop version, but when i try to transplant the hook i always get "This module cannot be transplanted to this hook." whaterer hook i select

i'm using the default theme for prestashop

any advise on that?

thanks

Share this post


Link to post
Share on other sites

  • 4 weeks later...

hi,

i installed the plugin on 1.5.3.1 prestashop version, but when i try to transplant the hook i always get "This module cannot be transplanted to this hook." whaterer hook i select

i'm using the default theme for prestashop

any advise on that?

thanks

 

This is a common problem of the module hook system of prestaShop. It has a very simple solution: Imagine that you want to transplant the module to the rightColumn Hook, but the module throws you aun error sayint thet you can't, because the module only let's you transplant to the leftColumn hook. The only thing you have to do is to add the proper hook function redirecting to the other function in the <name_of_the_module>.php file:

 

public function hookRightColumn($params){
 return $this->hookLeftColumn($params);
}

 

After that, you can happily transplant he module to right column :lol:

Edited by vidorado (see edit history)

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Thanks a lot for the module.

 

It was just what I was looking for, but I'm stuck at database settings. I can't get link with DB.

 

What should I write at "WordPress Post Host"? Blog URL, or server's, or WP admin? I've tried several things but always get 'Link to databasa cannot be established'. Both databases PS and WP are in the same server.

And, "WordPress Posts User" and password is the same we use for entering WP backoffice?

 

I'd appreciate any help. Thanks in advance.

Share this post


Link to post
Share on other sites

  • 4 weeks later...
What should I write at "WordPress Post Host"? Blog URL, or server's, or WP admin?

 

In Wordpress Host you put your server's connection to the database. In most cases is 'localhost'. It's the same value as the field "_DB_SERVER_" on your settings.inc.php file in prestashop or "DB_HOST" on your wp-config file in wordpress.

Share this post


Link to post
Share on other sites

  • 2 months later...
  • 2 weeks later...
  • 2 weeks later...

Hi

i have a problem with parameters on PS1.4.10

 

Link to database cannot be established.

 

I put my prefix-databe in the module

create a table as indicated,

but it's doesnt work

Where is teh mistake ?

thanks for your help !

Main Settings

Module Display Title WordPress Posts Host WordPress Posts User WordPress Posts Password WordPress Posts Base WordPress Posts Table Qty

Share this post


Link to post
Share on other sites

  • 5 weeks later...

The demo on first post doesn't work would love to see a working demo of this before I try but maybe i'll do a fresh install just to see it! Thanks for the mod this is going in the right direction!

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hello and congrats for this great and simple module. I have installed it on my PS 1.5.3.1 and works great, and i also included some tweaks posted by the users on this post. However i'd like to know, if possible, how can i do to show only the first image, or not showing any of the images related to the post.

 

Thank you in advance!

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 2 months later...

Hello,

 

I keep on getting this message while trying to make it work:

 

This module cannot be transplanted to this hook.

 

What am I doing wrong?

 

 

If I transplant it to the main page (the only one which allows me to do this, I get an error message while loading the page.

 

My version is 1.5.4.1

 

Thank you

Share this post


Link to post
Share on other sites

  • 5 months later...

Hello,

 

I keep on getting this message while trying to make it work:

 

This module cannot be transplanted to this hook.

 

What am I doing wrong?

 

 

If I transplant it to the main page (the only one which allows me to do this, I get an error message while loading the page.

 

My version is 1.5.4.1

 

Thank you

Look at this: http://www.prestashop.com/forums/topic/135334-modulefree-wordpress-bridge/page-2?do=findComment&comment=1117026

Share this post


Link to post
Share on other sites

  • 10 months later...

Hi leeburridge,

 

I have a website http://www.scooponpets.com where I use WordPress as a CMS installed in the root directory. And I also have prestashop in a subfolder at http://scooponpets.com/shop/

 

I want the users that are logged in on my site on the WordPress part, to be able to log in the shop (prestashop part) and vice versa, with one password - without having to create two different accounts and logins.

 

Is this possible? If yes, what would be the best approach to take.

 

Thank you for your time.

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 11 months later...
  • 2 weeks later...
  • 6 months later...
Guest
This topic is now closed to further replies.
 Share

×
×
  • Create New...

Important Information

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