Hi every one.

I have been asked to create a web page by a friend of mine (he decided to cash in some favours) I have setup a Drupal test server for him and he has asked me if I can create a specific page that lists Regions and then breaks down the regions into suburbs. What he then want is if his client clicks on for example

Link a they will be directed to a page that is automatically generated from a template all the text is static the only dynamic content that will be generated is the name of the suburb is generated from the link that was created in the previous page.

Kind of like whats done in Microsoft Word example:

{formtext}
My name is :{formtext}

I {formtext} hereby declare blah blah bla

In the above instance the formtext is carried from the decleration on the site on the links page the client may click on link "a" and this would generate a page from a template that has services for his business listed and the "a" is carried from the link that was pressed.

Then a second user comes from location "b" a page will be generated from the same template and a page is generated from the template that again lists the generic services he provides but in this case it would reference location "b".

How is this done in Html ? or is there a script that can do this?

I dont really want to create '00's of duplicate pages for all the suburbs if this can be done thru templates and passing information back into the template from the links page.

Thanks
ikhan42

Dani AI

Generated

This is a standard server-side templating task: one template, many dynamic pages. For a Drupal site the cleanest solution is to model Regions/Suburbs in Drupal (taxonomy or a Suburb content type with a Region reference) and use Views or the taxonomy term page to render a single template that receives the suburb identifier from the URL and inserts the suburb name into the static text.

Suggested Drupal workflow:

  • Create a vocabulary (or a content type) for locations; make Regions parents and Suburbs children, or give each Suburb a Region reference.
  • Build a Views page that lists services and add a contextual filter (Taxonomy term ID or term name) taken from the URL. The view header/body can hold your static copy and use Views replacement tokens (the contextual value or fields) to print the suburb name.
  • Give the view a URL pattern like /locations/% and use Pathauto for friendly slugs if desired. For theming, override the view or term template in the theme (Drupal 8+/Twig or Drupal 7 template files) if the layout needs more control.

If not using Drupal, a minimal PHP example (sanitize input, map slug to DB id for safety):

$slug = isset($_GET['suburb']) ? trim($_GET['suburb']) : '';
$slug = htmlspecialchars($slug, ENT_QUOTES, 'UTF-8');
// lookup full suburb name by slug from DB, then:
echo "<h1>Services in {$suburb_name}</h1>";
// include static service list below

Notes and gotchas: prefer server-side rendering for SEO (AJAX is optional for UX only), always validate/sanitize the URL value and map slugs to IDs to avoid tampering, add canonical URLs and unique titles/meta tags (Metatag/Token in Drupal) to prevent duplicate-content issues, and use Views caching for performance. This approach avoids creating hundreds of static pages and matches the direction hinted at by and ; ’s move-to-PHP comment is relevant only if the site isn’t staying in Drupal.

Recommended Answers

All 3 Replies

This cannot be done with HTML or CSS. Try PHP.

Regards
Arkinder

Move to PHP forum.

This is done with the help of Ajax and php. You sound like Google maps bt on a small scale.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.