close ad
 
Important WebAssist Announcement
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

url path confusion

Thread began 11/17/2015 2:00 am by Jamie | Last modified 11/20/2015 2:22 pm by Ray Borduin | 2630 views | 17 replies |

Jamie

url path confusion

Hi Ray

Getting myself a little confused (easy I know!). with regards to yesterdays prem I am trying to get the front end product results page results to link through to the relevant product but with the RS we set up for the level above, am a lot confused what I am doing....just need to get the panels to link through

domain.co.uk/shop/top-cat/sub-cat/productname

The htaccess is currently using

RewriteRule ^shop/(.*)/(.*)$ shop_product_results_s.php?perm=$2 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)$ shop_category_results_s.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]

and the page is attached and live page in PM

Also, trying to show a message should there be no products listed but it doesnt show the message (it starts at line 193 on the attached)

Sign in to reply to this post

Ray BorduinWebAssist

You have to add the two permalinks to the SELECT statement like:
"SELECT productcategories.CategoryName, productcategories_2.CategoryName AS parentcategoryname, productcategories.CatPermalink, productcategories_2.CatPermalink AS parentpermalink, products.* FROM productcategories INNER JOIN productcategories AS productcategories_2 ON productcategories_2.CategoryID = productcategories.CategoryParentID LEFT OUTER JOIN products ON products.ProductCategoryID = productcategories.CategoryID WHERE productcategories.Live = 1 AND productcategories.CatPermalink = ? ORDER BY productcategories.CategoryOrder ASC"

Then you can do your links like:

php:
<a class="link-text homepagePanelLink" href="shop/<?php echo($Categories->getColumnVal("parentpermalink")); ?>/<?php echo($Categories->getColumnVal("CatPermalink")); ?>/<?php echo($Categories->getColumnVal("ProductPermalink")); ?>"><?php echo($Categories->getColumnVal("ProductName")); ?></a>



and update your .htaccess to account for the product parameter like:

RewriteRule ^shop/(.*)/(.*)/(.*)$ shop_product_details_s.php?perm=$3 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)/(.*)$ shop_product_results_s.php?perm=$2 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)$ shop_category_results_s.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]
Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

right... i can see what you have done but to say i understand it would be a lie :( sorry but its a lot confusing

now I have to get the target product detail page set up and not sure how to modify the RS / htaccess further and allow the product details to be shown

Also, as you will see on the sub cat pages, there is a navigation set in the right hand column which replicates all the sub cats, I need to also do this on the product results pages and the product results pages so that it shows the sub cat categories on all of them....

also, do i need the recordset 'pagecontents' that I had created prior to usin gthe 'categories' one we created the other day?

$PageContents = new WA_MySQLi_RS("PageContents",$DBConnection,1);
$PageContents->setQuery("SELECT productcategories.*, settings.CompanyName, settings.Town, settings.County, settings.PostCode FROM productcategories, settings WHERE CategoryID = ? OR CatPermalink = ? AND Live = 1");
$PageContents->bindParam("i", "".(isset($_GET['id'])?$_GET['id']:"") ."", "-1"); //paramOffersID
$PageContents->bindParam("s", "".(isset($_GET['perm'])?$_GET['perm']:"") ."", "-1"); //paramPermalink
$PageContents->execute();

or has it become redundant?

Sign in to reply to this post

Ray BorduinWebAssist

You don't need that pagecontents recordset on the sub-page because we are getting the category name from the Categories recordset.

I've already given you the update the .htaccess for the product details page... now you can filter the recordset on the product details page using the perm url parameter filtered against the products permalink column.

You should be able to use INNER join to join the products table to the productcategories table and the parent categories in a new recodset to return all of the subcategories filtering by the products permalink. That query will look something like:

php:
<?php

$AllSubs 
= new WA_MySQLi_RS("AllSubs",$DBConnection,1);
$AllSubs->setQuery("SELECT productcategories.*, catParent.CategoryPermalink as ParentPermalink FROM productcategories INNER JOIN productcategories AS catParent ON catParent.CategoryID = productcategories.CategoryParentID WHERE  catParent.CategoryID = (SELECT CategoryParentID FROM products INNER JOIN productcategories ON CategoryID = ProductCategoryID WHERE ProductPermalink = ?) AND Live = 1");
$AllSubs->bindParam("s""".(isset($_GET['perm'])?$_GET['perm']:"")  ."""-1"); //paramPermalink
$AllSubs->execute();
?>



(my column and table names may be off since I'm not looking at your database, but that is the idea)

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

sorry... am completely confused on the RS for the product details page... I just dont understand how to modify the RS from the product results page to a) go to the correct product page and b) then to display the relevant product info

php:
<?php

$Categories 
= new WA_MySQLi_RS("Categories",$DBConnection,0);
$Categories->setQuery("SELECT productcategories.CategoryName, productcategories_2.CategoryName AS parentcategoryname, productcategories.CatPermalink, productcategories_2.CatPermalink AS parentpermalink, products.* FROM productcategories INNER JOIN productcategories AS productcategories_2 ON productcategories_2.CategoryID = productcategories.CategoryParentID LEFT OUTER JOIN products ON products.ProductCategoryID = productcategories.CategoryID WHERE productcategories.Live = 1 AND productcategories.CatPermalink = ? ORDER BY productcategories.CategoryOrder ASC");
$Categories->bindParam("s""".$_GET["perm"]  ."""-1"); //permparam
$Categories->execute();
?>
Sign in to reply to this post

Ray BorduinWebAssist

Just change the where clause from:
WHERE productcategories.Live = 1 AND productcategories.CatPermalink = ?

to:
WHERE products.ProductPermalink = ?

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

OK, have done that (and added products.ProductLive = 1 and getting a sql syntax error

Notice: Undefined index: perm in /home/motle7bk/public_html/clients/equicraft/shop-product-details_s.php on line 97

which references the variable line

php:
<?php

$Categories 
= new WA_MySQLi_RS("Categories",$DBConnection,0);
$Categories->setQuery("SELECT productcategories.*, productcategories_2.CatPermalink AS parentpermalink FROM productcategories INNER JOIN productcategories AS productcategories_2 ON productcategories_2.CategoryID = productcategories.CategoryParentID WHERE products.ProductLive = 1 AND products.ProdPermalink = ? ORDER BY productcategories.CategoryOrder ASC");
$Categories->bindParam("s""".$_GET["perm"]  ."""-1"); //permparam
$Categories->execute();
?>
Sign in to reply to this post

Jamie

OK, have done that (and added products.ProductLive = 1 and getting a sql syntax error

Notice: Undefined index: perm in /home/motle7bk/public_html/clients/equicraft/shop-product-details_s.php on line 97

which references the variable line

php:
<?php

$Categories 
= new WA_MySQLi_RS("Categories",$DBConnection,0);
$Categories->setQuery("SELECT productcategories.*, productcategories_2.CatPermalink AS parentpermalink FROM productcategories INNER JOIN productcategories AS productcategories_2 ON productcategories_2.CategoryID = productcategories.CategoryParentID WHERE products.ProductLive = 1 AND products.ProdPermalink = ? ORDER BY productcategories.CategoryOrder ASC");
$Categories->bindParam("s""".$_GET["perm"]  ."""-1"); //permparam
$Categories->execute();
?>
Sign in to reply to this post

Ray BorduinWebAssist

What URL are you using to access the page? The htaccess rule should be adding the perm URL parameter.

Sign in to reply to this post
Did this help? Tips are appreciated...

Jamie

ok, the htaccess is

RewriteRule ^shop/(.*)/(.*)/(.*)$ shop_product_details_s.php?perm=$3 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)/(.*)$ shop_product_results_s.php?perm=$2 [NC,L,QSA,T=application/x-httpd-php]
RewriteRule ^shop/(.*)$ shop_category_results_s.php?perm=$1 [NC,L,QSA,T=application/x-httpd-php]



an example of the on page link is shop/for-the-horse/bridles/product-7 which is being driven by the code shop/<?php echo($Categories->getColumnVal("parentpermalink")); ?>/<?php echo($Categories->getColumnVal("CatPermalink")); ?>/<?php echo($Categories->getColumnVal("ProdPermalink")); ?>

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...