3

I have the following problem: I would like to have one craft backend / one installation for different one pager sites on different domains. The reason is, that we have one HTML template we would like to use for our landing pages for different purposes (e.g. landingpage with different testimonials) and we would like to use a different domain for each version of the landingpage.

My initial thought was, to build a channel and to setup it up like www.domain.com/landingpage01, www.domain.com/landingpage02 etc.

So how do I route mycooldomain.com to /landingpage01 and myothercooldomain.com to /landingpage02?

Or are there any other solutions for my problem?

2 Answers2

2

One way to do this, is use different environments for each domain and set a variable (for instance, an entry ID) for each environment. So, your config/general.php would look something like this:

return array(
   '*' => array(
       // Every config setting that's the same for all domains (like devMode, omitScriptNameInUrls, etc.
   ),
   'firstDomain.com' => array(
       'siteUrl' => 'http://www.firstDomain.com/',
       'environmentVariables' => array(
           'baseUrl' => 'http://www.firstDomain.com/', // For use in asset source, for example
           'basePath' => '/path/to/public/folder/', // Same for this
           'entryId' => 5 // Or whatever the ID of your entry is
       ),
   ),
   'secondDomain.com' => array(
       'siteUrl' => 'http://www.secondDomain.com/',
       'environmentVariables' => array(
           'baseUrl' => 'http://www.secondDomain.com/', // For use in asset source, for example
           'basePath' => '/path/to/public/folder/', // Same for this
           'entryId' => 8 // Or whatever the ID of your entry is
       ),
   ),
);

Then, in your template (entry.html or whatever file you use as your section's template), you get the data like this:

{% set entry = craft.entries.id(craft.config.environmentVariables['entryId']).first() %}

<h4>{{ entry.title }}</h4>
Paul
  • 6,338
  • 12
  • 26
1

Found the solution:

I did as written above and added

{% include "landingpages/_entry" %}

to my index.html.

Thanks. I <3 Craft.