You are here:  » External.php Within Wordpress


External.php Within Wordpress

Submitted by Stew on Fri, 2014-09-26 09:58 in

Hi David,

Hope all's going well.

Apologies I think I've been through this one with you before(!) I'm creating a new WP site using external.php and just need to pull the individual product page into mysite.co.uk/product/?product=green-jumper for example.

As I know I've asked you this before I'm attempting to create a bare-bones fresh WP site using PT and thus if I ever look at creating a new site again I can refer to this new site.

The site I'm building is {link saved}, a product results page for example is:

{link saved}

at present when you click on a product you end up here:

{link saved}

which is outside of the WP template,

If I can create a page /product/ and pull the product result into that page that would be great...

Will see what you think?

Many Thanks,

Submitted by support on Fri, 2014-09-26 10:27

Hello Stew,

Rather than the external files had you thought about using the plugin itslef? The latest version (3.0) currently in beta but not having revealed any significant issues so far includes functionality to actually import product pages as actual WordPress posts, so that might be exactly what you require. Note that you don't necessarily need to use the import functionality - the latest version can work in "virtual" mode exactly as previous versions of the plugin whereby product pages appear as /product/Product-Name.html directly from within your wp template...

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Fri, 2014-09-26 11:07

Hi David,

Many thanks for the reply on this much appreciated. Have just taken a look through the wordpress plugin, we've started working on the current install & coding with PT external is it possible we can tweak the current external.php for this install - and then ongoing we'd look to use the WP plugin?

Will see if possible,

Submitted by support on Fri, 2014-09-26 14:39

Hi Stew,

Not easily at all i'm afraid - it's because so many users wanted to use WordPress as the front end that I developed the plugin as a replacement for the external script(s) so it would really be worthwhile implementing the plugin rather than attempting to modify the external scripts for tighter integration. The plugin works really well - version 2 was modified to work with all the popular SEO plugins, and version 3 (currently in beta) further modified to import product pages directly into WordPress as posts (you may or may not want to use that) so that would really be the way forward. If you're not sure of any of the steps, just let me know and I'll help you out with the migration...

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Fri, 2014-09-26 15:27

Hi David,

Many thanks for the reply - and makes sense have just installed the plugin :)

Have gone through the install and configured but for some reason I'm not getting any results showing up here:

{link saved}

but I am here:

{link saved}

any ideas?

Thanks,

Submitted by support on Fri, 2014-09-26 15:45

Hello Stew,

Almost certainly, it is just the requirement that for use with the plugin, that WordPress and Price Tapestry are sharing the same physical MySQL database.

For WordPress and Price Tapestry to be sharing a database the values for DB_NAME, DB_USER and DB_PASSWORD from wp-config.php must match exactly $config_databaseName, $config_databaseUsername and $config_databasePassword respectively in your Price Tapestry installation's config.php. This should not cause any problems since WordPress uses a default database table prefix of "wp_" (or a random value depending on version) and Price Tapestry uses "pt_"

Don't forget that you can use the Database Tool if you need to move your Price Tapestry database - run a Backup before changing config.php; after making changes and re-running setup.php then do the Restore using the backup XML file and finally re-import all feeds...

The final verification to make is that if not using the default value for $config_databaseTablePrefix in , $config_databaseUsername and $config_databasePassword respectively in /pt/config.php that the corresponding setting in wp-admin > Settings > PriceTapestry.org is configured to match.

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Fri, 2014-09-26 16:09

Hi David,

Many thanks there - I moved the DB and products now showing up :-) many thanks.

One thing, the product URL is currently:

http://www.example.com/product/red-mens-jumper.html/

Is there a way I can I get the URL to be as per:

http://www.example.com/product/?product=red-mens-jumper/

Submitted by support on Sat, 2014-09-27 08:57

Hi Stew,

Just a bit of info first - the trailing "/" is due to the Permalink setting of your WordPress installation. If you change to a permalink that does not end in "/" then this will not appear - the default "Numeric" type is ideal, or if you want your other posts to use Post Name then as a Custom Structure you can use:

/%postname%

If you wish to change the link structure you need to synchronise 2 points in the code. Firstly, in pto_common.php you will find the pto_common_productHREF() function, and any changes made here should correspond with changes to the virutal rewrite rule for "/product/" (by way of $pto_config_productBaseHREF variable) at line 554 of pto.php.

Using a ? in a re-written URL would be complex because of its significance in URL structure - however if your requirement was simply to access the product name elsewhere in your site the product name is in the global variable $pto_product, or via $_GET[] as $_GET["pto_product"].

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Sun, 2014-09-28 12:54

Hi David,

Many thanks for that - the plugin looks & works great.

Will adjust the permalink structure to /%postname% - thanks.

Re the URL am attempting to not have a static page for any of the products, and use a variable like:

http://www.example.com/product/?product=red-mens-jumper/

Currently category pages use a static URL such as:

http://www.example.com/mens-jumpers/

and have used the shortcode: [pto search="mens jumper"] which works fantastic.

I just need to figure our how to get to a variable URL instead of a static URL - have looked at the pto_common_productHREF() function but to be honest am not sure where to change, the plugin does everything needed which is fantastic :-) just figuring out how to get the URL?

Submitted by support on Mon, 2014-09-29 09:11

Hello Stew,

The easiest thing to do - and this would only require modification to the pto_common_productHREF() function is simply to use the variable version of the URL. To try this, edit pto_common.php and look for the following code at line 64:

return get_bloginfo('url').$pto_config_productBaseHREF.pto_common_hyphenate($product->normalised_name).".html";

...and REPLACE with;

global $pto_config_permalink;
return get_bloginfo('url')."/?pagename=".$pto_config_permalink."&pto_module=product&pto_product=".pto_common_hyphenate($product->normalised_name);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Mon, 2014-09-29 10:16

Hi David,

Great - many thanks, have just implemented that and now have a product URL of:

http://www.example.com/?pagename=/shopping/&pto_module=product&pto_product=mens-blue-jumper-size-7

This will work for what we need I think - but do you think there's a way to get a slightly cleaner URL similar perhaps to:

http://www.example.com/shopping/?pto_module=product&pto_product=mens-blue-jumper-size-7

Will see what you think,

Thanks

Submitted by support on Mon, 2014-09-29 10:38

Hello Stew,

In fact, that should work fine because WordPress will automatically set pagename by virtue of the permalink, so have a go with just:

global $pto_config_permalink;
return get_bloginfo('url').$pto_config_permalink."?pto_module=product&pto_product=".pto_common_hyphenate($product->normalised_name);

Cheers,
David.
--
PriceTapestry.com

Submitted by Stew on Mon, 2014-09-29 11:07

Hi David -

That's fantastic - that code worked straight away! Many thanks for going through that - appreciated,

Thanks,