You are here:  » Shortcodes


Shortcodes

Submitted by henk on Tue, 2012-11-13 21:06 in

Hello David,

I like to setup a page with shortcode [pto atoz="category"] = electronics
On this page will be all subcat categories is this possible?

Thx
Henk

Submitted by support on Wed, 2012-11-14 09:17

Hi Henk,

That would actually be a search results shortcode, using:

[pto search="category:Electronics"]

Cheers,
David.
--
PriceTapestry.com

Submitted by henk on Wed, 2012-11-14 09:24

Hello David,

I could do that but the filter isn't on this page.

Thx
Henk

Submitted by support on Wed, 2012-11-14 09:48

Hi Henk,

Ah - OK, probably best support with a completely custom shortcode handler but have a go with something like this; firstly, in pto_atoz.php look for the following code at line 43:

$sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;

...and REPLACE with:

$parts = explode(":",$module);
if (($parts[0]=="category") && (isset($parts[1])))
{
  $module = "category";
  $category = $parts[1];
  $sql = "SELECT DISTINCT(subcat) AS category FROM `".$pto_config_databaseTablePrefix."products` WHERE category='".$wpdb->escape($category)."' AND subcat <> '' ORDER BY subcat";
}
else
{
  $sql = "SELECT DISTINCT(".$module.") FROM `".$pto_config_databaseTablePrefix."products` WHERE ".$module." <> '' ORDER BY ".$module;
}

And then where the link is generated, look for the following code at line 107:

$itemURL = get_bloginfo('url').$$baseHREFVar."/".pto_common_hyphenate($row->$module);

...and REPLACE with:

if ($category)
{
  global $pto_config_permalink;
  $itemURL = get_bloginfo('url').$pto_config_permalink."?q=category:".urlencode($category)."&subcatFilter=".urlencode($row->$module);
}
else
{
  $itemURL = get_bloginfo('url').$$baseHREFVar."/".pto_common_hyphenate($row->$module);
}

...should be close!

Cheers,
David.
--
PriceTapestry.com

Submitted by henk on Wed, 2012-11-14 10:15

Almost, atoz is correct:

http://www.linkik.com/beeld-en-geluid

I use shortcode:

[pto atoz="category:Beeld en geluid"]

But the link through next isn't correct.

Thx
Henk

Submitted by support on Wed, 2012-11-14 10:18

Sorry Henk should be pto_q in the URL. The last replacement:

if ($category)
{
  global $pto_config_permalink;
  $itemURL = get_bloginfo('url').$pto_config_permalink."?pto_q=category:".urlencode($category)."&pto_subcatFilter=".urlencode($row->$module);
}
else
{
  $itemURL = get_bloginfo('url').$$baseHREFVar."/".pto_common_hyphenate($row->$module);
}

Cheers,
David.
--
PriceTapestry.com

Submitted by henk on Wed, 2012-11-14 10:31

Yep almost,

subcatFilter = pto_subcatFilter

Thx
Henk

Submitted by support on Wed, 2012-11-14 10:36

Ah yes, corrected above! Brain was in PT mode this morning...!

Cheers,
David.
--
PriceTapestry.com