-
- 1,336 Posts
Yes, here's the call :-
[[!mmlCache?
&element=`pdoResources`
&parents=`0`
&resources=`[[*id]]`
&tpl=`storyItemDetails_[[!++cultureKey]]`
&includeTVs=`[[mmlGetTemplateTVs]]`
&prepareTVs=`1`
&processTVs=`1`
&includeContent=`1`
&tvPrefix=``
&loadModels=`migxmultilang`
&prepareSnippet = `mmlTranslatePdoToolsRow`
&cache=`0`
]]
here's the template :-
-----
<div class="seven columns alpha">
<p>[[!+mml_description]]</p>
</div>
<div class="four columns omega">
<ul class="uploadDetails">
<li><strong>Uploaded by:</strong>[[!+modx.user.id:userinfo=`username`]]</li>
<li><strong>Approximate date of item:</strong>[[!*publishedon:strtotime:date=`%a %b %e, %Y`]]</li>
<li><strong>Location:</strong>[[!+mml_location]]</li>
<li><strong>County:</strong>[[!+mml_county]]</li>
<li><strong>Creator:</strong>[[!+mml_creator]]</li>
<li><strong>Tags:</strong>[![!articleCreateTagList]]</li>
</ul>
<p>[[+comments_enabled:is=`1`:then=` <a href="[[~[[*id]]]]#comments" class="comments">Comments ([[+comments_count]])</a>`]]</p>
</div>
-----
here's what ends up on the page :-
-----
<p>[[!+mml_description]]</p>
</div>
<div class="four columns omega">
<ul class="uploadDetails">
<li><strong>Uploaded by:</strong>janice-mem</li>
<li><strong>Approximate date of item:</strong>Mon Mar 17, 2014</li>
<li><strong>Location:</strong>[[!+mml_location]]</li>
<li><strong>County:</strong>[[!+mml_county]]</li>
<li><strong>Creator:</strong>[[!+mml_creator]]</li>
<li><strong>Tags:</strong></li>
</ul>
<p></p>
</div>
-----
Use MODx, or the cat gets it!
-
- 5,888 Posts
this is how I did set it up for testing, which does work without any issues,
see:
http://www.webcmsolutions.de/en/tests/storyitemdetails.html
template:
[[!mmlCache?
&element=`pdoResources`
&parents=`0`
&resources=`[[*id]]`
&tpl=`storyItemDetails`
&includeTVs=`[[mmlGetTemplateTVs]]`
&prepareTVs=`1`
&processTVs=`1`
&includeContent=`1`
&tvPrefix=``
&loadModels=`migxmultilang`
&prepareSnippet = `mmlTranslatePdoToolsRow`
&cache=`1`
]]
storyItemDetails:
<!doctype html>
<html lang="en">
<head>
<meta charset="[[++modx_charset]]">
<title>[[++site_name]] - [[+mml_pagetitle]]</title>
<base href="[[++site_url]]">
</head>
<body>
<div class="bg">
<div id="container">
<header>
[[!mml_LangLinks]]
</header>
[[!$storyItemDetails_[[++cultureKey]]]]
</div><!--end container-->
</div><!--end bg-->
</body>
</html>
storyItemDetails_de:
<div class="seven columns alpha">
<p>[[!+mml_description]]</p>
</div>
<div class="four columns omega">
<ul class="uploadDetails">
<li><strong>Hochgeladen von:</strong>[[!+modx.user.id:userinfo=`username`]]</li>
<li><strong>Datum des Datensatzes:</strong>[[!*publishedon:strtotime:date=`%a %b %e, %Y`]]</li>
<li><strong>Ort:</strong>[[!+mml_location]]</li>
<li><strong>Land:</strong>[[!+mml_county]]</li>
<li><strong>Ersteller:</strong>[[!+mml_creator]]</li>
<li><strong>Tags:</strong>[[!articleCreateTagList]]</li>
</ul>
[[!setPlaceholders? &comments_enabled=`1` &comments_count=`25`]]
<p>[[+comments_enabled:is=`1`:then=` <a href="[[~[[*id]]]]#comments" class="comments">Kommentare ([[+comments_count]])</a>`]]</p>
</div>
storyItemDetails_en:
<div class="seven columns alpha">
<p>[[!+mml_description]]</p>
</div>
<div class="four columns omega">
<ul class="uploadDetails">
<li><strong>Uploaded by:</strong>[[!+modx.user.id:userinfo=`username`]]</li>
<li><strong>Approximate date of item:</strong>[[!*publishedon:strtotime:date=`%a %b %e, %Y`]]</li>
<li><strong>Location:</strong>[[!+mml_location]]</li>
<li><strong>County:</strong>[[!+mml_county]]</li>
<li><strong>Creator:</strong>[[!+mml_creator]]</li>
<li><strong>Tags:</strong>[[!articleCreateTagList]]</li>
</ul>
[[!setPlaceholders? &comments_enabled=`1` &comments_count=`25`]]
<p>[[+comments_enabled:is=`1`:then=` <a href="[[~[[*id]]]]#comments" class="comments">Comments ([[+comments_count]])</a>`]]</p>
</div>
[ed. note: Bruno17 last edited this post 10 years, 1 month ago.]
-
- 1,336 Posts
Ok, sorted the above out thanks, got another litle prob, the links produced by the snippet mml_langLinks don't seem to preserve URL parameters, for instance I'm calling a page like this :-
dwsoga.com/en/searchresults?selector=theme&theme=xxxxxxxxxx
when I switch languages I get dwsoga.com/we/searchresults
but no parameters, hence the search results don't work.
Use MODx, or the cat gets it!
-
- 5,888 Posts
you can try this modified version
<?php
//[[!mml_LangLinks]]
$outputSeparator = $modx->getOption('outputSeparator', $scriptProperties, '');
$tpl = $modx->getOption('tpl', $scriptProperties, 'mml_LinkTpl');
$wrapper = '<ul class="mml_links">[[+output]]</ul>';
$wrapper = $modx->getOption('wrapper', $scriptProperties, $wrapper);
$cultureKey = $modx->getOption('cultureKey');
$site_url = $modx->getOption('site_url');
$furls = $modx->getOption('friendly_urls');
$packageName = 'migxmultilang';
$packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
$modelpath = $packagepath . 'model/';
if (is_dir($modelpath)) {
$modx->addPackage($packageName, $modelpath, $prefix);
}
$classname = 'mmlLang';
$c = $modx->newQuery($classname);
$output = array();
//$c->sortby('pos');
if ($collection = $modx->getCollection($classname, $c)) {
$qs = $modx->request->getParameters();
if ($furls == '1') {
$url = $modx->makeUrl($modx->resource->get('id'), null, $qs);
$base_url = $modx->getOption('base_url');
if ($url == $base_url) {
$url = '';
}
$site_url = str_replace('/' . $cultureKey . '/', '', $site_url);
}
foreach ($collection as $object) {
$lang_key = $object->get('lang_key');
$class = ($lang_key == $cultureKey) ? 'class="active"' : '';
$row = $object->toArray();
if ($furls == '1') {
$lang_key = !empty($lang_key) ? $lang_key . '/' : '';
$row['link'] = rtrim($site_url, '/') . '/' . $lang_key . $url;
} else {
$qs['cultureKey'] = $lang_key;
$row['link'] = $modx->makeUrl($modx->resource->get('id'), null, $qs );
}
$row['class'] = $class;
$output[] = $modx->getChunk($tpl, $row);
}
}
$output = implode($outputSeparator, $output);
$output = str_replace('[[+output]]', $output, $wrapper);
return $output;
[ed. note: Bruno17 last edited this post 10 years, 1 month ago.]
I know that "A foolish consistency is the hobgoblin of little minds", but it is irritating that all of the mml snippets have the naming convention of "mmlSnippetName", except for mml_LangLinks. I have enough trouble remembering the names of the snippets without that!
I've started to seriously work with this finally. Followed instructions from the github readme.md. Added four languages. The mml_LangLinks is just producing empty UL tags, no rows.
If I understand correctly, the language of the main resource fields is the default language, and no translating needs to be done for this language. I do need to create an entry in the Languages for it, but it does not need to appear in the TV.
Figured out what the problem with the mml_LangLinks is. It is adding
to the query, but there is no 'pos' field in the database. This is with a new installation with Package Manager.
Another issue has appeared. The [[+content]] placeholder does not work in the case of the default language, where the TV is not being used for the default. Adding the [[*content]] tag to the template adds the default content to all pages.
-
- 5,888 Posts
The pos-field should have been added to the db-schema, the same time I've added the sortby('pos')
https://github.com/Bruno17/migxmultilang/commit/25f73fa996cadf24c1bf2c1872c0d89385c07304#diff-2aa14185797917b75b0fe55856de3fd7R10
I think, I will do a fresh install and see what happens working thrue the setup-instructions
I'm starting all over myself, as well as updating my localhost MAMP installation. I noticed that you have a more recent version on github than the one from Package Manager, which is rc3.
Ok, installing the latest version from github handles the LangLinks correctly, and the field is in the database.
The [[+content]] still doesn't output anything for the default language. And using both the placeholder and the regular resource [[*content]] tag puts both. This means that it is necessary to use the TV for the default language.
[ed. note: sottwell last edited this post 10 years, 1 month ago.]