Search

Hello,

Just quickly, this is my second symphony project and I’m loving this sytem!

Now, the question:

Is there any way to leave the URL Handle field blank when editing a Page?

What I’m trying to do is to have one page like http://mysite/products that lists all the products (just their names).

Then I would like to have each product page like http://mysite/products/aproduct that shows all the product details.

I’m completely stuck here, I cannot recreate this url structure. I would like to use different data sources for each task (products list and product detail).

Thanks for your help

Balint

Yep, this is standard bread-and-butter functionality. You’ll have two pages:

  • Home, add the “Index” page type and it will become the default index page
  • Products

When you create your product page, enter “Products” as the page title, leave URL Handle blank (it’ll be filled in for you, but you can change it) and enter product-name into the URL Parameters box. This will create two routes:

http://mysite/products
http://mysite/products/{$product-name}

The URL Parameter product-name is optional, so you can view the Products page with and without it, so you get two page routes with one.

Then create your two Data Sources:

  • Products List (selects all products, no filters)
  • Product Detail (filters product name field with {$product-name}

Actually, you should also add $product-name to the “Required URL Parameter” box on your Product Detail data source. This will ensure this DS only executes when you’re viewing a product (when that URL Parameter has a value).

You’ll then want to add some XSLT to conditionally show either the products list or a product detail, depending on the XML provided to the page.

(Also, welcome to the forums Balint! Awesome avatar.)

I’ve tried this strategy, but isn’t it wasting cycles when generating a single product page?

I checked the XML output for a single product page and it also contains all the results from the “Products List” data source (the names of all the other products).

I checked the XML output for a single product page and it also contains all the results from the “Products List” data source (the names of all the other products).

This is by design, since you specified you wanted to use two separate DSs (one for each), so I figured you might need the Products List DS on the Product Detail page so you could list the other products in a sidenav etc.

If you don’t need this, then you can use a single “Product” Data Source. Set it up the same as your Products List DS, but add the filter from the Product Detail DS. When the filter value ({$ds-product-name}) evaluates to nothing, the filter will be ignored. This means that on /products the DS will return all products, but on /products/my-product-name the DS filter will kick in and the DS should return only one product.

Thank you for the reply! It’s working but…

What about the products listing page? On this page all I need is just the names, but the XML contains all the other details too… It’s more theoretical, I don’t think at our scale the speed difference would be an issue, I’m just curious what would be the perfect solution.

Edit your Products List DS and deselect the fields that you don’t need in the Included Elements box at the bottom of the form.

Thanks, I think i will open a new discussion, because the original title is misleading…

(The problem is that I cannot create a sub-page of an existing page and use a different data source. It’s easier if I ask this in a new thread.)

@nickdunn: this avatar has a long history, when I was studying in France eight years ago…

When the detailed route is shown could I still use the DS with all products in order to create next and previous products? How can I manage that? thank you guys!

A few ideas for Previous/Next articles are covered here: http://getsymphony.com/discuss/thread/256/. Not sure if there has a been a definitive solution since this discussion though.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details