简体   繁体   中英

How to dynamically change the base url in drupal 7

I'm developing a site for different city so for each city the URL is different

  1. For example the URL is like this www.test.com/city1 and the second URL is like www.test.com/city2 so according to the city name the block should change in the home page , so if city1 is losangles then display content related to losangles in blocks should display

  2. Now if I want to go to the next page my URL should be www.test.com/city1/about like this i am using content type city to differentiate it while creating this menu i got page not found error

i am new to Drupal please help me

I think you are asking it in wrong way. In terms of drupal the base url is the url to the root directory in which drupal is running. check here drupal base_url . Your question is not much clear but let me try to answer what i understood from your question.

If each city have its own page then you can do it with creating different block for each city then showing that related block only at related page.

If you want to do it dynamically and show different block on a page on the basis of what is passed in end of url like show block 1 if end of url is /city1, show block 2 if end of url is /city2. There are multiple ways to do it. You can use context module. You can create different block for each city, then with the context module you can set context on the basis of path, and set the action accordingly. For example in context module set the path context if path end like /city1 then do action "show block1", set another path context if path end like /city2 then do action show block2. Context module's UI is quite simple and self explanatory.

Another way is using views module.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM