Thomas Sutton | 22 Jun 06:06

SPIP sites with multiple domain names

Hi all,

We've got a project coming up with some unusual requirements, so I  
thought I'd ask on the list if anyone has any advice.

We will be building a SPIP site for a client which will be accessed  
using a number of different domain names. Depending on the domain  
name used, the site will have to display different content from a  
different rubrique or secteur using a different set of templates  
(product-specific "micro-sites").

Changing the templates is reasonably easy, if a little cumbersome, in  
`mes_options.php`:


> switch ( $_SERVER['SERVER_NAME'] ) { > case 'domain1.net': > $GLOBALS['dossier_squelettes'] = "templates/domain1"; > break; > case 'domain2.com': > $GLOBALS['dossier_squelettes'] = "templates/domain2"; > break; > default: > $GLOBALS['dossier_squelettes'] = "templates/default"; > break; > }
Handling the different content, though, I'm not sure about. My current plan is to have a sector per site and have `{parent=...}` in the `sommaire.html` in each template directory, but this is inelegant. Can I add an `{id_secteur=...}` criterion to all (applicable) loops in the appropriate `case` statement above? Ideally, I'd like to move the above code into a plug-in and manage all this from the back-end. Which pipeline is appropriate to set the ` $dossier_sequelettes` and other globals in this manner? I'm also hoping to get some of the values from `spip_meta` done as well (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is there a better way to do this rather than overriding `balise_NOM_SITE_SPIP_dist($p)`, etc? Finally -- though it should probably have been first :-) -- is there already a plug-in to do this sort of thing? Cheers, Thomas Sutton bouncingorange
Fil | 22 Jun 23:00
Favicon
Gravatar

Re: SPIP sites with multiple domain names

> We will be building a SPIP site for a client which will be accessed using a
> number of different domain names. Depending on the domain name used, the
> site will have to display different content from a different rubrique or
> secteur using a different set of templates (product-specific "micro-sites").

Several sites are already doing this, based on language
(http://www.poureva.be/ / http://www.vooreva.be/) or based on a
keyword added to articles (papamamanbebe.net and survivreausida.net).

> Changing the templates is reasonably easy, if a little cumbersome, in
> `mes_options.php`:

Yes.

You'll also probably need to change the urls/xxx.php file so that it
gives the absolute URL with the correct domain too (I can send you
survivreausida.net's urls file).

> Handling the different content, though, I'm not sure about. My current plan
> is to have a sector per site and have `{parent=...}` in the `sommaire.html`
> in each template directory, but this is inelegant. Can I add an
> `{id_secteur=...}` criterion to all (applicable) loops in the appropriate
> `case` statement above?

This is a matter of site structure, of course. But you certainly can
overload the definition of any BOUCLE with a function boucle_XXXX.
There are examples in
plugins/zone/exclure_secteur/exclure_sect_fonctions.php:
function boucle_RUBRIQUES($id_boucle, &$boucles) {

> Ideally, I'd like to move the above code into a plug-in and manage all this
> from the back-end. Which pipeline is appropriate to set the
> `$dossier_sequelettes` and other globals in this manner?

The plugin would be great.

Any file called in <options>...</options> is called early enough to
set the globals.

For URLs you'll have to play a bit with the code

> I'm also hoping to get some of the values from `spip_meta` done as well
> (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is there a better
> way to do this rather than overriding `balise_NOM_SITE_SPIP_dist($p)`, etc?

For #NOM_SITE_SPIP you could use a <multi>, or override it.
For #URL_SITE_SPIP you could rewrite the function so that it uses
$_SERVER['xxxx']

> Finally -- though it should probably have been first :-) -- is there already
> a plug-in to do this sort of thing?

No, but once it's coded it will be useful for many people!  (hence,
tested and supported)

-- Fil
Thomas Sutton | 24 Jun 04:15

Re: SPIP sites with multiple domain names

Hi Fil,

On 23/06/2009, at 5:00 AM, Fil wrote:

>> We will be building a SPIP site for a client which will be  
>> accessed using a
>> number of different domain names. Depending on the domain name  
>> used, the
>> site will have to display different content from a different  
>> rubrique or
>> secteur using a different set of templates (product-specific  
>> "micro-sites").
>
> Several sites are already doing this, based on language
> (http://www.poureva.be/ / http://www.vooreva.be/) or based on a
> keyword added to articles (papamamanbebe.net and survivreausida.net).

Good to know. I'm glad I'm not trying to do the impossible.

>> Changing the templates is reasonably easy, if a little cumbersome, in
>> `mes_options.php`:
>
> Yes.
>
> You'll also probably need to change the urls/xxx.php file so that it
> gives the absolute URL with the correct domain too (I can send you
> survivreausida.net's urls file).

That would be very helpful! Thanks!

>> Handling the different content, though, I'm not sure about. My  
>> current plan
>> is to have a sector per site and have `{parent=...}` in the  
>> `sommaire.html`
>> in each template directory, but this is inelegant. Can I add an
>> `{id_secteur=...}` criterion to all (applicable) loops in the  
>> appropriate
>> `case` statement above?
>
> This is a matter of site structure, of course. But you certainly can
> overload the definition of any BOUCLE with a function boucle_XXXX.
> There are examples in
> plugins/zone/exclure_secteur/exclure_sect_fonctions.php:
> function boucle_RUBRIQUES($id_boucle, &$boucles) {

I've seen this, but haven't had cause to look at the Boucle AST or  
the boucle_* functions before. Is there not some global variable to  
add criteria to loops as there is to add filters to all uses of a  
certain tag?

>> Ideally, I'd like to move the above code into a plug-in and manage  
>> all this
>> from the back-end. Which pipeline is appropriate to set the
>> `$dossier_sequelettes` and other globals in this manner?
>
> The plugin would be great.
>
> Any file called in <options>...</options> is called early enough to
> set the globals.

Great! That's even easier than I was expecting. I've started writing  
a plug-in based on what little I have so far (basically just the  
snippet in my first e-mail) and this works well.

> For URLs you'll have to play a bit with the code
>
>> I'm also hoping to get some of the values from `spip_meta` done as  
>> well
>> (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is there a  
>> better
>> way to do this rather than overriding `balise_NOM_SITE_SPIP_dist 
>> ($p)`, etc?
>
> For #NOM_SITE_SPIP you could use a <multi>, or override it.
> For #URL_SITE_SPIP you could rewrite the function so that it uses
> $_SERVER['xxxx']
>
>> Finally -- though it should probably have been first :-) -- is  
>> there already
>> a plug-in to do this sort of thing?
>
> No, but once it's coded it will be useful for many people!  (hence,
> tested and supported)

The site this is for will be supported long-term and we're expecting  
to use it on multiple projects in the future, so we will be  
developing and maintaining it for the foreseeable future.

Regards,

Thomas Sutton
bouncingorange
Fil | 24 Jun 09:34
Favicon
Gravatar

Re: SPIP sites with multiple domain names

>> You'll also probably need to change the urls/xxx.php file so that it
>> gives the absolute URL with the correct domain too (I can send you
>> survivreausida.net's urls file).
>
> That would be very helpful! Thanks!

I've sent it to you. But be warned; this file is "old" in the sense
that it doesn't use the most recent API for URLs. Anyway, it might
give you an idea -- and in any case this functionality is something we
need to find in the new plugin, if we're all going to use it.

>> There are examples in
>> plugins/zone/exclure_secteur/exclure_sect_fonctions.php:
>> function boucle_RUBRIQUES($id_boucle, &$boucles) {
>
> I've seen this, but haven't had cause to look at the Boucle AST or the
> boucle_* functions before. Is there not some global variable to add criteria
> to loops as there is to add filters to all uses of a certain tag?

No, but when a BOUCLE is defined, a few default SQL criteria are set
(like e.g. statut='publie' ); this function boucle_XXXX is where it
happens, and this is where you would add the new default criteria
(like e.g. lang='zh' or id_secteur NOT IN (xxx)).

>> No, but once it's coded it will be useful for many people!  (hence,
>> tested and supported)
>
> The site this is for will be supported long-term and we're expecting to use
> it on multiple projects in the future, so we will be developing and
> maintaining it for the foreseeable future.

Yes, same here. A good reason to develop it on the Zone :-)

-- Fil
Thomas Sutton | 26 Jun 04:17

Re: SPIP sites with multiple domain names


On 24/06/2009, at 3:34 PM, Fil wrote:

>>> You'll also probably need to change the urls/xxx.php file so that it
>>> gives the absolute URL with the correct domain too (I can send you
>>> survivreausida.net's urls file).
>>
>> That would be very helpful! Thanks!
>
> I've sent it to you. But be warned; this file is "old" in the sense
> that it doesn't use the most recent API for URLs. Anyway, it might
> give you an idea -- and in any case this functionality is something we
> need to find in the new plugin, if we're all going to use it.

It certainly does. Thanks.

>>> There are examples in
>>> plugins/zone/exclure_secteur/exclure_sect_fonctions.php:
>>> function boucle_RUBRIQUES($id_boucle, &$boucles) {
>>
>> I've seen this, but haven't had cause to look at the Boucle AST or  
>> the
>> boucle_* functions before. Is there not some global variable to  
>> add criteria
>> to loops as there is to add filters to all uses of a certain tag?
>
> No, but when a BOUCLE is defined, a few default SQL criteria are set
> (like e.g. statut='publie' ); this function boucle_XXXX is where it
> happens, and this is where you would add the new default criteria
> (like e.g. lang='zh' or id_secteur NOT IN (xxx)).

It looks like I have some more "SPIP-learning" to do then. :-)

I probably won't bother too much at the moment, but it would probably  
be a good idea for this to be very general and allow the web-master  
to add rules like:

If hostname == 'my.domain.com' then all RUBRIQUES loops should have:
	lang='zh'
	id_secteur=23
	id_mot=16

>>> No, but once it's coded it will be useful for many people!  (hence,
>>> tested and supported)
>>
>> The site this is for will be supported long-term and we're  
>> expecting to use
>> it on multiple projects in the future, so we will be developing and
>> maintaining it for the foreseeable future.
>
> Yes, same here. A good reason to develop it on the Zone :-)

Indeed it is. Once I something working for my purposes, I'll commit  
it. What do you think is a good name? "Microsites" might be a little  
bit too restricted given the uses others have for it (especially the  
domain-based translation).

Can someone point me to a good example of the "state of the art" for  
writing plug-ins (I've seen the thread on spip-dev@, but haven't  
bothered to feed it to Google Translate yet). In particular, I've  
seen two or three different ways to handle installation, creating  
tables, etc. Which is the newest, best, most future-proof way?

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design
Gilles VINCENT | 26 Jun 08:29
Picon
Gravatar

Re: SPIP sites with multiple domain names

Can someone point me to a good example of the "state of the art" for writing plug-ins (I've seen the thread on spip-dev <at> , but haven't bothered to feed it to Google Translate yet). In particular, I've seen two or three different ways to handle installation, creating tables, etc. Which is the newest, best, most future-proof way?

IMHO : 
programmer.spip.org, with doc.spip.org (and especially the shortcuts http://doc.spip.org/ <at> function_name) are the best way to learn how to create plugins.

For the private area, Cedric indicates these plugins : 

I would also add the plugin Agenda 2.0.
(generally, choose the plugins developped by Fil and Cedric ;) )

.Gilles


 

Regards,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design

Thomas Sutton | 26 Jun 08:49

Re: SPIP sites with multiple domain names

Hi Gilles,

On 26/06/2009, at 2:29 PM, Gilles VINCENT wrote:

> Can someone point me to a good example of the "state of the art"  
> for writing plug-ins (I've seen the thread on spip-dev@, but  
> haven't bothered to feed it to Google Translate yet). In  
> particular, I've seen two or three different ways to handle  
> installation, creating tables, etc. Which is the newest, best, most  
> future-proof way?
>
> IMHO :
> programmer.spip.org, with doc.spip.org (and especially the  
> shortcuts http://doc.spip.org/ <at> function_name) are the best way to  
> learn how to create plugins.

I've haven't got that far into programmer.spip.org yet. I only read  
it as I translate, and I haven't felt like learning some more French  
recently. :-)

> For the private area, Cedric indicates these plugins :
>
> http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/forum
> http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/sites
> http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/ 
> urls_etendues
> http://zone.spip.org/trac/spip-zone/browser/_plugins_/ 
> gestion_documents
>
> I would also add the plugin Agenda 2.0.
> (generally, choose the plugins developped by Fil and Cedric ;) )

I'll use these as examples then. Thanks.

And those trac links are dead, by the way.

Cheers,

Thomas Sutton

Web Developer
bouncingorange
graphic + web design
Gilles VINCENT | 26 Jun 23:55
Picon
Gravatar

Re: SPIP sites with multiple domain names


For the private area, Cedric indicates these plugins :

http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/forum
http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/sites
http://zone.spip.org/trac/spip-zone/browser/_core_/plugins/urls_etendues
http://zone.spip.org/trac/spip-zone/browser/_plugins_/gestion_documents

I would also add the plugin Agenda 2.0.
(generally, choose the plugins developped by Fil and Cedric ;) )

I'll use these as examples then. Thanks.

And those trac links are dead, by the way.


The problem with Trac is now resolved. Sorry it was my fault if Trac did crash :/

 

Cheers,


Thomas Sutton

Web Developer
bouncingorange
graphic + web design

RealET | 22 Jun 16:53
Picon
Gravatar

Re: SPIP sites with multiple domain names

* Thomas Sutton tapuscrivait, le 22/06/2009 06:06:

> I'm also hoping to get some of the values from `spip_meta` done as well > (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is there a > better way to do this rather than overriding > `balise_NOM_SITE_SPIP_dist($p)`, etc?
Why not uses <multi> ? -- -- RealET
Thomas Sutton | 23 Jun 05:16

Re: SPIP sites with multiple domain names

Hi,

On 22/06/2009, at 10:53 PM, RealET wrote:


> * Thomas Sutton tapuscrivait, le 22/06/2009 06:06: >> I'm also hoping to get some of the values from `spip_meta` done as >> well (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is >> there a better way to do this rather than overriding >> `balise_NOM_SITE_SPIP_dist($p)`, etc? > Why not uses <multi> ?
Because it's all in English, and I don't like "hijacking" features like translation to do stuff like this. Hopefully, they'll grow and a need multi-lingual version soon as well! :-) It's going to be a corporate web-site, with a number of "micro-sites" for their products. Regards, Thomas Sutton bouncingorange
L'oiseau2nuit | 22 Jun 15:47
Picon

Re: SPIP sites with multiple domain names



On Mon, Jun 22, 2009 at 5:06 AM, Thomas Sutton <thomas-wT9aXh5S2t8LQszSOs697tBPR1lH4CV8@public.gmane.org> wrote:

Finally -- though it should probably have been first :-) -- is there already a plug-in to do this sort of thing?

Hi Thomas,

Actually no plugin deals with this. I've allready made this research for a quite similar project coming on soon too (1 website, 2 Languages, 1 domain per language ...)

That's why I'll follow your topic with interest

Thanks a lot for the first pieces of code.

>> I'm also hoping to get some of the values from `spip_meta` done as well
>> (`#NOM_SITE_SPIP` and `#URL_SITE_SPIP`, in particular). Is there a better way to do
>> this rather than overriding `balise_NOM_SITE_SPIP_dist($p)
>>`, etc?

Probably using some 'champs_extras' on the secteurs, then replacing the #URL_SITE_SPIP et #NOM_SITE_SPIP tags by your own #MY_SITE_NAME & #MY_SITE_URL  but I'm not sure that's the best solution.




--
Etienne Brackers.
http://www.loiseau2nuit.net

| Laurence J. Peter  - "If two wrongs don't make a right, try three."

Gmane