Take the 2-minute tour ×
Drupal Answers is a question and answer site for Drupal developers and administrators. It's 100% free, no registration required.

I am working on a site that the client required a dynamic url creation for a huge number of keywords for each city (for example). So the result url would be like www.domain.com/city/citname/keyword.

And each URL shall direct to a page which has the same content except the city name and keyword.

So I directly thought of taxonomies, but when I reached the development stage ... it was very hard to apply this over Drupal. I think of making two vocabularies one for the cities and the other for keywords as keywords are repeated the same for each city.

Summery: every city should have all the keywords connected to it

So, If my approach is good, how to mix two vocabulary? and how to maintain one content for all resulted taxonomy terms.

I hope it is clear

best,

share|improve this question

1 Answer 1

From an SEO perspective I'm not sure its a great idea, I have little experience optimizing for SEO. But....

If the title of your Node is the cityname. I would simply make its url path pattern in Pathauto as city/[node:title].

That takes care of the url /city/cityname.

Then you can simply use the Tagging taxonomy installed by default to tag the city with relevant keywords.

Then install the 3rd party contributed module: view_mode_page

It allows you to define alternate pattern(s) to get to a piece of Node content.

Then use its API to create the alternate urls based on the tags.

Something like this example code in a custom module (untested, as I dont have your exact setup):

/**
 * Implementation of hook_view_mode_page_get_patterns() from module
 * view_mode_page.
 *
 * This lets me define additional node urls (per NID) with a custom
 * view mode.
 *
 * Creating a custom view mode, and using Display Suite for example could let
 * you customize these pages so they're slightly more unique in content layout
 * and values.
 */
function MYMODULE_view_mode_page_get_patterns($results, $content_type, $view_mode) {
  $results = array();
  $defaults = array('content_type' => 'CITY_CONTENT_TYPE', 'view_mode' => 'full' /* or a custom view mode */, 'show_title' => 0, 'title' => '');

  // Load the terms for keyword vocabulary by its vocabulary name.
  $keyword_terms = taxonomy_get_tree(taxonomy_vocabulary_machine_name_load('city_keywords')->vid);

  // Loop through the Term objects and build the sub-url using the nodes pathauto alias denoted by %.
  foreach ($keyword_terms as $pos => $Term) {
    $results[$pos] = (Object) array_merge($defaults, array('url_pattern' => '%/'.$Term->name));
  }
  return $results;
}

If every city is to have different keywords, this may not work. Or you may have to load all the city nodes and iterate through them to get the correct paths and attached keyword terms. This is just taking a generic keywords list and building additional urls for each city.

share|improve this answer
    
Dear tenken,I would like to thank you for your useful reply and method. In fact, I am not thinking of creating node or content types as all the data resides in excel sheets and needed to be imported - it is very huge data (cities, keyword, statistics ....) - so I created tables from them and did not use content types. If I am on the wrong track I appreciate your suggestions –  fadifannoun Dec 18 '12 at 18:06
1  
Well you probably really want "Drupal content" of this data at some point. And should consider making a Node or Entity out of your data. the Migrate module can help you easily move your Excel data into drupalized native content types. Or even the Feeds module. –  tenken Dec 18 '12 at 18:23

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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