You are here:  » How to


How to

Submitted by alexnn on Tue, 2018-08-07 18:08 in

Hi David,
Can you please explain how...
There is such a structure.
There are many authors, and there are many books with release dates.
Base HREF /authors/

I would like to display WP page (as a "Homepage") containing thumbs(featured image) of the author's pages sorting by category.
Then on the author's page there is featured image, description, location (birthplace of the author as custom taxonomies) and a list of all current author books sorting by release date with release dates (as custom fields).
And Book page as WP post contain comparison table (thats Okay).

link as
/Adventures/authors/Mark-Twain/The-Adventures-of-Tom-Sawyer/

Help me to understand how to do it, and how to make such page as a "Homepage" that links to author's pages and author's page links to book(as WP post)?
How to create a author's pages (with PT) if the book exists in feed?
How to create custom taxonomies?
Also any idea how best to organize it?
I'm new, so bear with me )

Thank you!

Submitted by support on Wed, 2018-08-08 07:34

Hello Alex and welcome to the forum!

Taking this one step at a time; how have you set-up and imported your feed(s) within the Price Tapestry back end ( /pt/admin/ )?

Whilst Price Tapestry supports custom fields, what I would suggest, if this is not what you are already doing is to use the Brand field to hold the author, so you would have category (e.g. Adventure) and brand (e.g. Mark Twain).

With that in place, with the plugin installed using all defaults, and the Search Filters widget enabled, you should be able to browse to

/productcategory/Adventure

And then filter the results by Brand, selecting "Mark Twain" giving you the URL:

/shopping?pto_q=category%3AAdventure%3A&pto_merchantFilter=&pto_brandFilter=Mark+Twain&pto_minPrice=&pto_maxPrice=

That would be the first step - let me know once you have that or close to it set-up and then I'll guide you through the steps of creating clean URLs mapping to the above e.g.

/productcategory/Adventure/author/Mark-Twain/

etc.

...(including renaming "Brand/brand" throughout to "Author/author" etc...

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Wed, 2018-08-08 10:07

>( /pt/admin/ )
Yes it is !

Submitted by support on Wed, 2018-08-08 11:19

Hi Alex,

Great - just to confirm, you're at the point where you can browse category results filtered by author (brand at the moment) e.g.

/shopping?pto_q=category%3AAdventure%3A&pto_merchantFilter=&pto_brandFilter=Mark+Twain&pto_minPrice=&pto_maxPrice=

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Thu, 2018-08-16 11:57

Hi David,
I'm not ready yet, but I continue to do ...
While there is a setting of filters .... one question on the case ....
If each product_name contains country name, and each country name are added as custom fields (name "country").
For example
product_name = "The Adventures of Tom Sawyer USA"
country = "USA"
I want to delete(filter) "USA" automatic from the product_name.

RegExp filter like /(.*)(%DB_country%)/ does not work

Is this possible in this way?

Submitted by support on Thu, 2018-08-16 12:15

Hello Alex,

Check out this comment for a mod to the Search and Replace filter to enable placeholder support in the search (and replace) values.

18/06A now includes support for both feed and database field placeholders - use %fieldname% for a field name from the feed, or {fieldname} for a database / custom field - so {country} is what you need in this case...

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Sat, 2018-08-18 13:17

Is this possibly for the Search and Replace RegExp filter?

Submitted by support on Sun, 2018-08-19 07:41

Hello Alex,

Sure - for Search and Replace RegExp, edit html/filter.php and look for the following code at line 76:

    return trim(preg_replace($filter_data["search"],$filter_data["replace"],$text));

...and REPLACE with:

    $filter_data["search"] = filter_recordPlaceholders($filter_data["search"]);
    $filter_data["replace"] = filter_recordPlaceholders($filter_data["replace"]);
    return trim(preg_replace($filter_data["search"],$filter_data["replace"],$text));

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Mon, 2018-08-20 13:37

Hi, David!
I followed all the instructions, but Filter does not work.
Can you verify that I'm doing wrong?
I added custom field "country" to db.
There is %field_2% in my feed that contains text - "country : USA", and I get the {country} from this field.
1. I registre %field_2% contains text - "country : USA" as {country}. Its Ok!
2. Than i use Filter Type Explode for {country} to get only "USA" . Its Ok!
3. Than Search and Replace RegExp for "product_name" that contain text "The Adventures of Tom Sawyer USA"
Search:
/{country}/
Replace : (space) Does not work!

I would like to get "product_name" "The Adventures of Tom Sawyer", but return "The Adventures of Tom Sawyer USA".
But it works:
Search:
/USA/
Replace : (space) Its Ok!
I tried different ways
with Search and Replace Filter too, Search: {country} Replace : (space), but also does not work.
It all looks like it does not see the placeholder {country}.
or am I doing something wrong?

Submitted by support on Mon, 2018-08-20 15:10

Hello Alex,

I think I can see what might be happening...

The Explode filter does not trim (remove leading or trailing white space) from the returned value, because sometimes you might want this. So if you are using just ":" as the Explode Character or String, then your `country` value would actually become "(space)USA"

If you edit the Explode filter and include the spaces either side of the colon e.g. " : " (without the quotes) as the Explode Character or String, then the return value should be just "USA" and the subsequent Search and Replace RegExp filter should then work as expected...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Tue, 2018-08-21 14:09

Hi David,
thanks for the hint, I did as you said, but it seems there is not a lot of extra gaps.
I made a check and tried another way and I think I understood why this is happening.
I tried adding the "Text After" filter in the "Product Name" field and added "+ {country}" that I received ...
"The Adventures of Tom Sawyer USA + country: USA"
For some reason, the field %field_2% - "country: USA" is not converted to "USA" when it comes to the "product_name" field.
I tried adding "+ %field_2%", and I got the same thing ... "The Adventures of Tom Sawyer USA + country: USA"
I got into the database and found the {country} field and it contains exactly "USA" ie. its work Search and Replace RegExp for getting "USA" from %field_2% ...
I go to Feed Utilities> Imported Analysis and find column {country} and he was clean "USA".
Why does the {country} ("USA") field not appear in the "product_name" field, but the full contents of "country: USA"? Any ideas?
The sequence of filters is also respected, I do it at the very end. First I get {country}, then "Text After".
I tried this in another feed, but I get the same result.
I tried to add a "Text After" filter to "description" field .... "bla bla {country}" and get "bla bla country: USA" instead of "bla bla USA".

So, if this custom field varchar (255), for example like {country} to me, has any preliminary conversion to get a part of the string (i use Search and Replace RegExp) before, then it is substituted in full, and not the selected part.
How can I fix this and use a clean {country} into filters Search and Replace, Text After to Product Name and Description fields?

Submitted by support on Wed, 2018-08-22 07:18

Hello Alex,

Ah, my apologies, I should have spotted this earlier - the $filter_importRecord array, used by {fieldname} placeholders is not affected by any previous filters affecting database fields.

To correct this, edit includes/admin.php and look for the following code at line 254:

        $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);

...and REPLACE with:

        $importRecord[$filter["field"]] = $execFunction($filter["data"],$importRecord[$filter["field"]]);
        $filter_importRecord[$filter["field"]] = $importRecord[$filter["field"]];

Your sequence should then work as expected and the clean "USA" as {country} available to use in Text After with the Product Name...

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by alexnn on Thu, 2018-08-23 20:38

Hello David,
I also made some more settings...
And I am ready to continue what I started above

/productcategory/Adventure
/shopping?pto_q=category%3AAdventure%3A&pto_merchantFilter=&pto_brandFilter=Mark+Twain&pto_minPrice=&pto_maxPrice=

its works

Submitted by support on Fri, 2018-08-24 10:39

Hi Alex,

Next step would be to add and test the rewrites. To do this, edit the plugin file pto.php (wp-content/plugins/pto) and look for the following code at line 939:

  $newrules[$b.'$'] = 'index.php?pagename='.$pto_config_permalink.'&pto_module=brand';

...and REPLACE with:

  $newrules[$b.'$'] = 'index.php?pagename='.$pto_config_permalink.'&pto_module=brand';
  $newrules[$c.'/(.*)/author/(.*)/(.*).html$'] = 'index.php?pagename='.$pto_config_permalink.'&pto_q=category:$matches[1]:&pto_brandFilter=$matches[2]&pto_page=$matches[3]';
  $newrules[$c.'/(.*)/author/(.*)$'] = 'index.php?pagename='.$pto_config_permalink.'&pto_q=category:$matches[1]:&pto_brandFilter=$matches[2]';

Edit pto_search.php and look for the following code at line 64:

  $pto_brandFilter = (isset($pto_brandFilter)?$pto_brandFilter:"");

...and REPLACE with:

  $pto_brandFilter = (isset($pto_brandFilter)?pto_common_normalise($pto_brandFilter):"");

And then the following code beginning at line 688:

      if (
         ($pto_sort == "relevance")
         &&
         ($pto_minPrice.$pto_maxPrice.$pto_merchantFilter.$pto_categoryFilter.$pto_brandFilter == "")
         )
      {
        $baseHREFVar = "pto_config_".$parts[0]."BaseHREF";
        $navigationBaseHREF = get_bloginfo('url').$$baseHREFVar."/".pto_common_hyphenate($parts[1])."/";
        $rewrite = TRUE;
        break;
      }

...and REPLACE with:

      if (strpos($_SERVER["REQUEST_URI"],"?")===FALSE)
      {
        $baseHREFVar = "pto_config_".$parts[0]."BaseHREF";
        $navigationBaseHREF = get_bloginfo('url').$$baseHREFVar."/".pto_common_hyphenate($parts[1])."/";
        if ($pto_brandFilter) $navigationBaseHREF .= "author/".pto_common_hyphenate($pto_brandFilter)."/";
        $rewrite = TRUE;
        break;
      }

...and you should now have rewrites working as follows;

/productcategory/Adventure/author/Mark-Twain

Also double check that pagination is working for category / author combination with more than the configured results per page (10 by default)...

Cheers,
David.
--
PriceTapestry.com