2

I've installed the pathauto module. I have a content type article. When I'm trying to create an article, the path is created automatically in the form content/article-title, that is fine.

However, I want to pass some dummy values via url like content/article-title/value1, content/article-title/value2. So now I have multiple aliases for the url. I will create some functionality using this dummy value.

If I try to access node/10/value1, I can access the page. But I want to access with path alias like content/article-title/value1.

How can I access a page using content/article-title/value1, content/article-title/value1 and content/article-title?

I don't need to create multiple path alias for url. But I need to access page using above urls.

Is it possible?

Answer:

Eventually, I got the solution for this. Please refer http://www.phponwebsites.com/2016/08/drupal-7-pathauto-multiple-url-alias.html

1

You need to set path at config >> URL aliases >> patterns under that article patter you need to set something like.

content/[node:title]/[node:field_machine_name]

You can access with pattern url otherwise you can access by default with "node/nid".

  • It is not based on field. It is a custom value. I need to pass 2 values like value1 and value2 – Guru Sep 29 '15 at 5:41
  • which kind of value you want to pass? – vgoradiya Sep 29 '15 at 5:48
  • String like sum and non-sum – Guru Sep 29 '15 at 5:51
  • just enter in tags for sum or non-sum and use that field in content/[node:title]/[node:field_tag] – vgoradiya Sep 29 '15 at 5:58
  • Where to do this? and how? – Guru Sep 29 '15 at 6:00
0

You should consider passing the values as parameters instead of arguments.

Arguments:

  • content/article-title/value1
  • content/article-title/value2

Parameters:

  • content/article-title?key1=[value1]&key2=[value2]

Parameters will mean you can still have a single path alias for your node.

You pick up parameters in your code by looking in the global $_GET variable.

  • Yes we could do this but it affects SEO. – Guru Sep 29 '15 at 6:01
  • A great deal of how to handle this is going to depend on what you're doing with it. How do you plan to add the functionality? Server-side? Client-side? – Darvanen Sep 29 '15 at 6:27
  • For client side validation – Guru Sep 29 '15 at 6:29
  • You will need mutliple aliases for each node then. I'm not sure pathauto will do that for you but you should be able to write a custom module that adds new items to the aliases settings (/admin/config/search/path) using functions from the pathauto module. – Darvanen Sep 29 '15 at 6:32
  • Yes i need to do. Is any other options like while create node? – Guru Sep 29 '15 at 6:33
0

You will need multiple aliases for the same node.

Create a custom module that uses hook_node_insert() to trigger a function that uses path_save() to add a new alias for the node.

path_save only overwrites paths if you direct it to do so with $path['pid'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.