We have 14 domain names pointing to a single HTML page. We would like to put a couple of e-mail addresses on this page depending the domain the user came from. e.g. <a href="mailto:support@%domain_name%">Support<a>
So, if "%globals_asset_url%" = "http://www.example.com/" what keyword equals "example.com" please?
I figure that “%globals_server_SERVER_NAME%” should give "www.example.com" but I can’t get rid of the www :-/
Is there a Keyword Modifier for replacing text? Something like %globals_server_SERVER_NAME^remove:www.% could work!?
Disclaimer: I am really really sorry if this is a basic or stupid question, I have never touched Mysource Matrix before today and am just filling in while we find a new webmaster. I have spent all mourning on this site and Google before posting so I'm hoping I haven't made a complete fool of myself!
Thank you very much in advance.
Keyword for the domain name
Welcome! All questions are welcomed - no fools, only students here.
That being said, I don't think (correct me if I'm wrong 3.22.2+ guys) there is a keyword for what you are looking for. I personally write this kind of thing in manually, I hardly ever have the need to thinking about it.
Sorry for not being any further help! Goodluck learning MySource Matrix.
Yeah, just looked at the newest keyword modifiers, and there are none for what you need.
But, you could use a little jQuery to do what you want.
Use your keyword like this:
Test email address
Your link would turn into
Test email address
Then add some jQuery to remove the www. and add your mailto text along with your cleaned up domain.
// Remove www from link var s = $('a.myLink'); var domain = s.attr('rel'); domain = domain.split('www.'); domain = domain[1]; s.attr('href', 'mailto:support@'+domain);
It's a bit of a hack and I'm not sure it would work without testing… but if you created a metadata schema with a metadata value of 'mail domain' and applied it to each of the sites, then couldn't you access that value via the metadata keywords?
Wow, thank you for the responses!
nnhubbard, Unfortunately we need for the addresses to be read by other machines so javascript isn't ideal I'm afraid (typical isn't it, we spend most of the time hiding e-mail addresses)! Sorry.
Douglas Davey, this sounds really promising!? I think we are a little scuppered though as we have one site with 14 domains (hostnames) against it and not 14 sites. I could be wrong though. How would you add a meta-tag against each domain name individually?
Thank you all for help.
I must admit that I'm surprised in looking at the keyword modifiers (http://manuals.matrix.squiz.net/concepts/chapters/keyword-modifiers) that there isn't a substring modifier. That would be very handy for situations like this - Dogsbody wrote:
[quote]
Douglas Davey, this sounds really promising!? I think we are a little scuppered though as we have one site with 14 domains (hostnames) against it and not 14 sites. I could be wrong though. How would you add a meta-tag against each domain name individually?
[/quote]
If it is one site with multiple domains/hostnames, metadata might not be a solution - do you have different designs on the different domains? My understanding of designs is kinda fuzzy, but if you can have the design differ from domain to domain, and can use a different customisation per domain, perhaps therein lies a solution?
I just wrote a custom keyword modifier that does just what you want. If you have access to editing your system, open up the text.inc file located at <matrix_root>/fudge/general/text.inc
Then, look around line 294 and add the following:
// ### Added by Nic Hubbard ### case "strreplace": // Strip the passed string from the keyword $args = implode(':', $modifier['args']); return str_replace($args, '', $text);
Now, you can easily use the new keyword modifier: %globals_server_SERVER_NAME^strreplace:www.%
Which, will now return something like mydomain.com without the www.
:)
I cannot wait for it!:lol:
the new modifier I wish to have: ^regex:pattern~replacement
:lol:
Edit: added wish
Sorry for delay in coming back to this, as I say, I'm just filing in for someone!
Unfortunately I don't have access to the install
I was wondering if I could hack it somehow, as it's only 14 domains can I do something like…
if (%globals_server_SERVER_NAME% = "www.example.com") {%domain_name% = "example.com"} elseif (%globals_server_SERVER_NAME% = "www.example.net") {%domain_name% = "example.net"} else (%globals_server_SERVER_NAME% = "www.example.org") {%domain_name% = "example.org"} Info Sales Support
... what is the correct markup for this please?
Thank you again!