I'm just trying to get this set up to prove that I can do it.
I have worked through the
CMP tutorial.
My index.php file looks like this:
<?php
$modx->lexicon->load('mycmp:default');
return 'Hello from my CMP!';
?>
This is my default.inc.php file in my /lexicon/en folder:
<?php
$_lang['mycmp'] = 'This is my CMP!';
$_lang['mycmp.menu_desc'] = 'This is a description of my CMP!';
$_lang['mycmp.message'] = 'A special message for you!';
$_lang['mycmp.magic_word'] = 'xyzzy';
?>
Everything shows up just fine inside MODx-- the first two strings from the english lexicon show up in the dropdown under components and when I click on it, the text "Hello from my CMP!" appears as expected.
Everything works so far!
In the content box for my home page I put this:
Hello!
[[%key? &topic=`magic_word` &namespace=`mycmp` &language=`en`]]
...
When I hit "view", a new tab opens in my browser that says "Hello! key ..."
This is not what I expected. I wanted to see "xyzzy" instead of "key".
Similarly, when I change my index.php file to this:
<?php
$modx->getService('lexicon','modLexicon');
$modx->lexicon->load('mycmp:default');
$modx->lexicon->load('en:mycmp:magic_word');
return $modx->lexicon('en:mycmp:magic_word');
//return 'Hello from my CMP!';
?>
The text that appears when I click on my component says "en:mycmp:magic_word".
This also is not what I expected.
I have tried several variations of these commands, but none of them work.
What am I doing wrong?
Update:
[[%magic_word? &namespace=`mycmp` &topic=`default`]]
This tag returns "magic_word". Not good!
Same thing with this: [[%magic_word? &namespace=`mycmp` &topic=`default` &language=`en`]]
Update 2:
I have added this tag to my content:
[[LoadLexicon? &topic=`mycmp`]]
And added in this snipped:
<?php
$modx->getService('lexicon','modLexicon');
$modx->lexicon->load($topic);
return '';
Still not there!
Update 3:
Tried this style for the snippet call:
[
[!LoadLexicon? &input=`mycmp`]]
Not working, either.
[ed. note: coderjeff last edited this post 12 years, 10 months ago.]