Hope some of you great coders can help me with this (simple, I guess) question:
In my pagetitles I have for example: Betula nana L. ssp. tundrarum (Perfil.) Á.Löve & D.Löve. Another example: Bistorta vivipara (L.)S.F. Gray.
What I need is a snippet that returns the two first words in the pagetitle and put an underscore _ between them, like this:
Betula_nana or Bistorta_vivipara.
Can someone please help me making a snippet like this?
Thanks.
I think, thererfor I am! But what I am, and why...?
Thank you very much for the answer. Unfortunately it did not work. I tried it in a call like this:
<img src="assets/images/species/[!get-name!]_close.jpg" width="172px" height="170px" />
where my snippet get-name contain your code, but it did not work.
I think, thererfor I am! But what I am, and why...?
First I tried
return instead of
echo, but it didn’t work. Than I tried
<?php
$t =explode (' ',$modx->documentObject['pagetitle']);
echo 'Betula'.'_'.'nana';
?>
and the snippet returned what it was suppose to do.
Nothing in my System events.
I think, thererfor I am! But what I am, and why...?
Check the source of the html document to see if something is echoed and what.
Are you sure that ’pagetitle’ is the correct field and contains your words ?
Where do you call the snippet, from the same document id which you want retrieve the words ?
Thanks again. It was just a typo. Everything works great now.
I think, thererfor I am! But what I am, and why...?