Topic: The language hack has landed!  (Read 12227 times)

Pages: [1]   Go Down

#1: 25-Jul-2006, 11:15 AM

Coding Team
Carsten
Posts: 572

WWW
start of WARNING
You have to overwrite several files.  If you do and things get screwed up, blame yourself for not making copies, don't come whinning to me!
end of WARNING

 Smiley now that is out of the way ...

Ok folks, here is what I've been playing with.  Technically this should be alpha but after playing with this for a bit let's bump it to Beta 1.0  Grin

This is actually a hack that requires jazzing up a bit of the core code in several files.

- You will also need to add 1 field to the site_content table.
- The rest is just upload over previous files.

I've also included some examples for TVs and Chunks to get you going.

 Shocked This is only intended to be an interm solution until the new API for 1.0 comes out.  However, in the meantime this might be something useful.

Cheers!

EDIT:
here is my field for site_content, I just copied it from the dump for my db.  But it should help you add the field.
`lang` char(2) NOT NULL default 'en',

Clarification:
This allows you to do basically the same thing as Susan's cookie code.  Except now it is in the manager and you can change the language declaration as you would if it were published or not .... NOTE .... No quick right-click ability but rather you need to go to the "page settings" section when editing the document.

TO DO:
Figure out how to call 'lang' from the parser to cut down on the sql call that is needed in a TV.
Does anybody know how to do this?

* language_hack.zip (81.03 KB - downloaded 492 times.)
« Last Edit: 25-Jul-2006, 11:16 PM by Carsten »
Tangent-Warrior Smiley

#2: 25-Jul-2006, 04:17 PM

Foundation

rthrash
Posts: 11,348

WWW
OK... so what exactly does this language hack do?
MODx is a content managmeent framework that allows web professionals to turn over sites to end-users for daily maintenance without worrying. Please help us help you when asking for assistance and read the wiki. Searching the forums from the top level helps, too.
Ryan Thrash
MODx Co-Founder
Principal @ Collabpad
work productively.
work intelligently.
work together.

#3: 25-Jul-2006, 11:11 PM

Coding Team
Carsten
Posts: 572

WWW
Did you open it?  Tongue
Easy enough:

Joking aside:

If you install only the mutate page for the admin you can see that I put in a drop down menu that allows you to choose a language for the document. This way you can use a TV or something to allow you to do fun stuff without resorting to Susan's cookie method. You just have to run a simple sql call and then show what ever menu or what not.

ughhh I'm not doing well with words today.

anyway, if you've tried Susan's cookie hack then you should get the idea.  However, with this hack you don't have to worry about cookies and all that.  You just select your language and off you go.

EDIT:
This does work except that I can't seem to get the parser to allow me to do the "[*lang*]" trick.  If that could be hacked into the parser you wouldn't need the TV to run a separate sql query to identify the language of the document.  It's not a huge hit but ... one less query is always 1 less query Cheesy
« Last Edit: 25-Jul-2006, 11:18 PM by Carsten »
Tangent-Warrior Smiley

#4: 26-Jul-2006, 01:23 AM

Coding Team

sottwell
Posts: 10,527

WWW
Limiting the lang field to two characters may come back to haunt you; http://www.loc.gov/standards/iso639-2/langcodes.html and http://www.w3.org/International/articles/language-tags/
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#5: 26-Jul-2006, 01:46 AM

Coding Team
Carsten
Posts: 572

WWW
Thanks Susan!

I was just thinking top domain type of thing.

.ru
.jp
ect ...
However, modifying the field wouldn't be that big of a problem.

so what do you think?  I was just taking off from what you did Cheesy
Tangent-Warrior Smiley

#6: 26-Jul-2006, 02:23 AM

Coding Team

sottwell
Posts: 10,527

WWW
well, I would think at least five, for example en-uk or en-us.

Maybe reading through this will help: http://www.ietf.org/rfc/rfc3066.txt

It looks like a 2 or 3 letter tag, a dash, then up to eight characters in the second subtag. So you could go as far as 11 characters.

Personally, I would go with five; if anybody wants to use i-klingon they can hack the database themelves! And in any case, a developer could simply use his own arbitrary designations if the standards don't fit his requirements.
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#7: 26-Jul-2006, 03:08 AM

Coding Team
Carsten
Posts: 572

WWW
now now now, some people really do speak klingon!
I'm sure that there are a few here too!

Smiley


I wish I did! Cheesy
Tangent-Warrior Smiley

#8: 26-Jul-2006, 04:38 AM

Coding Team

doze
Posts: 4,099

....Boom!

I think that japanese users would need 9 chars atleast... Look at this. So maybe just go with the toal 11 chars, what does it hurt..  Cheesy

EDIT: Oh, just remembered that you Carsten live in Japan, so I guess you know better lol Grin
New MODx wiki! Please help up with documentation efforts! || Old Wiki

"He can have a lollipop any time he wants to. That's what it means to be a programmer."

#9: 26-Jul-2006, 04:54 AM

Coding Team
Carsten
Posts: 572

WWW
ahhh, ok, looks like my original idea is taking a different direction Cheesy

I was just thinking of a simple non-text encoding approach.

Just something simple.

ie: ja vs shift-jis  (japanese example)



hmmm, which would work better for the largest share of users?
Tangent-Warrior Smiley

#10: 26-Jul-2006, 07:54 AM

Coding Team

sottwell
Posts: 10,527

WWW
I understand what you mean, but it's still a good idea to make sure users will have as much flexibility in their useage as possible. Be sure if you don't that you'll have a dozen developers PMing you and posting with their complaints!
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#11: 29-Jul-2006, 11:41 AM

Moderators
madmage
Posts: 167

Carsten, I think it should be better to put forces together in order to avoid duplicating efforts...

Do you know MY multilanguage hack?

You should...

#12: 29-Jul-2006, 11:49 AM

Marketing & Design Team

davidm
MODx evangelist
Posts: 7,073

The best way to predict the future is to invent it

WWW
It's great to have options, true. Everyone has different priorities for their MODx projects, and we're numerous needing a full fledged true multilingual MODx... but right now, it's not there.

My take on things is : Susan's method is by far simpler and efficient enough... madmage's solution was indeed pretty appealing and I was very much in favor of it. I didn't test yours Carsten, but knowing what lies ahead, I think the lightest and more flexible solution (which means Susan's) is the way to go, pending the 1.0 branch...
.: nodeo.net : Pour un web libre, moderne et ouvert ! :: david-molliere.net : Suivez en "live" mes expérimentations et billets sur les CMS et autres applications web :.

*** Forums modxcms.fr Participez à l'élaboration du site MODx francophone ! ***

! Nouveau !  En live, ne manquez pas les news de modxcms.fr sur Twitter   ! Nouveau !

MODx est l'outil idéal pour les developpeurs et webdesigners qui cherchent un framework de gestion de contenu hautement flexible et performant, tout en étant simple d'accès pour les utilisateurs finaux.

Config : Apache 2.2.8 - MySQL 5.0.67 - PHP 5.2.8 | Debian 4.0 (Etch)

Réalisations sous MODx : | pargade-notaires.fr | soleil.info | gican.asso.fr | michelez-notaires.com | amadom.gerondicap.com | jocelyne-violet.net

#13: 15-Aug-2006, 03:20 PM

whitehat
Posts: 29

start of WARNING
You have to overwrite several files.  If you do and things get screwed up, blame yourself for not making copies, don't come whinning to me!
end of WARNING

 Smiley now that is out of the way ...

Ok folks, here is what I've been playing with.  Technically this should be alpha but after playing with this for a bit let's bump it to Beta 1.0  Grin

This is actually a hack that requires jazzing up a bit of the core code in several files.

- You will also need to add 1 field to the site_content table.
- The rest is just upload over previous files.

I've also included some examples for TVs and Chunks to get you going.

 Shocked This is only intended to be an interm solution until the new API for 1.0 comes out.  However, in the meantime this might be something useful.

Cheers!

EDIT:
here is my field for site_content, I just copied it from the dump for my db.  But it should help you add the field.
`lang` char(2) NOT NULL default 'en',

Clarification:
This allows you to do basically the same thing as Susan's cookie code.  Except now it is in the manager and you can change the language declaration as you would if it were published or not .... NOTE .... No quick right-click ability but rather you need to go to the "page settings" section when editing the document.

TO DO:
Figure out how to call 'lang' from the parser to cut down on the sql call that is needed in a TV.
Does anybody know how to do this?


Can you please post the snippet     DropMenuPlus      thnx

#14: 15-Aug-2006, 07:27 PM

Coding Team
Carsten
Posts: 572

WWW
DropMenuPlus -- is just dropmenu with a small hack. If I remember correctly the hack was something that let's you get the parent of the current category or like that ... jeez, I should remember things like this!

 Shocked

Code:
// ###########################################
// DropMenu                                  #
// ###########################################
// Configurable menu / navigation builder using UL tags
// Offers optional DIV wrappers for top level and nested menus (useful for hover zones)
// as well as configurable classes for the DIV, UL, and LI elements.  It even
// marks ancestors of and the current element with a hereClass (indicating you are here
// and in this area of the site).  Also applies .last CSS class to final LI in each UL.
//
// Developed by Vertexworks.com and Opengeek.com
// Feel free to use if you keep this header and credits in place
//
// Inspired by List Site Map by Jaredc, SimpleList by Bravado,
// and ListMenuX by OpenGeek
//
// Configuration parameters:
//
// &menuName        - name of a placeholder for placing the output in the layout
// &topnavClass     - CSS class for styling the class assigned to the outermost UL
//
// TO DO: configuration parameters above, more usage examples, CSS examples, output indenting

// ###########################################
// Usage Examples                            #
// ###########################################
// Creates menu with wrapping DIV with id=myMenu, starting at the site root, two levels deep,
// with descriptions next to the links, and nested UL elements with class=nestedLinks; output
// of menu can be placed in layout using placeholder named myMenu ( e.g. [ +myMenu+ ] )
// [[DropMenu? &menuName=`myMenu` &startDoc=`0` &levelLimit=`2` &topdiv=`true` &showDescription=`true` &subnavClass=`nestedLinks`]]
//
// Creates topMenu from site root, including only 1 level, with class=topMenubar applied to the top level UL
// and class=activeLink applied to current page LI
// [[DropMenu? &menuName=`topMenu` &startDoc=`0` &levelLimit=`1` &topnavClass=`topMenubar` &here=`activeLink`]]
//
// Creates dropmenu 3 levels deep, with DIV wrappers around all nested lists styled with class=hoverZone
// and currentPage LI styled with class=currentPage
// [[DropMenu? &levelLimit=3 &subdiv=true &subdivClass=hoverZone &subnavClass=menuZone &here=currentPage]]
//
// Creates dropmenu of infinite levels, ordered by menutitle in descending order
// [[DropMenu?orderBy=menutitle&orderDesc=true]]

// ###########################################
// Configuration parameters                  #
// ###########################################

// $phMode [ true | false ]
// Whether you want it to output a [+placeholder+] or simply return the output.
// Defaults to false.
$phMode = false;

// $menuName [ string ]
// Sets the name of the menu, placeholder, and top level DIV id (if topdiv
// option is true). Set to "dropmenu" by default.
$phName = (!isset($phName)) ? 'dropmenu' : "$phName";

// $siteMapRoot [int]
// The parent ID of your root. Default 0. Can be set in
// snippet call with startDoc (to doc id 10 for example):
// [[DropMenu?startDoc=10]]
$siteMapRoot = 0;

// $removeNewLines [ true | false ]
// If you want new lines removed from code, set to true. This is generally
// better for IE when lists are styled vertically.
$removeNewLines = (!isset($removeNewLines)) ? false : ($removeNewLines==true);

// $maxLevels [ int ]
// Maximum number of levels to include. The default 0 will allow all
// levels. Also settable with snippet variable levelLimit:
// [[DropMenu?levelLimit=2]]
$maxLevels = 0;


// $textOfLinks [ string ]
// What database field do you want the actual link text to be?
// The default is pagetitle because it is always a valid (not empty)
// value, but if you prefer it can be any of the following:
// menutitle, id, pagetitle, description, parent, alias, longtitle, introtext
// TO DO: set text to be first non-empty of an array of options
$textOfLinks = (!isset($textOfLinks)) ? 'menutitle' : "$textOfLinks";

// $titleOfLinks [ string ]
// What database field do you want the title of your links to be?
// The default is pagetitle because it is always a valid (not empty)
// value, but if you prefer it can be any of the following:
// menutitle, id, pagetitle, description, parent, alias, longtitle, introtext
$titleOfLinks = (!isset($titleOfLinks)) ? 'description' : "$titleOfLinks";

// $pre [ string ]
// Text to append before links inside of LIs
$pre = (!isset($pre)) ? '' : "$pre";

// $post [ string ]
// Text to append before links inside of LIs
$post = (!isset($post)) ? '' : "$post";

// $selfAsLink [ true | false ]
// Define if the current page should be a link (true) or not (false)
$selfAsLink = (!isset($selfAsLink)) ? false : ($selfAsLink==true);

// $hereClass [ string ]
// CSS Class for LI and A when they are the currently selected page, as well
// as any ancestors of the current page (YOU ARE HERE)
$hereClass = (!isset($hereClass)) ? 'here' : $hereClass;



// $showDescription [true | false]
// Specify if you would like to include the description
// with the page title link.
$showDescription = (!isset($showDescription)) ? false : ($showDescription==true);

// $descriptionField [ string ]
// What database field do you want the description to be?
// The default is description. If you specify a field, it will attempt to use it
// first then fall back until it finds a non-empty field in description, introtext,
// then longtitle so it really tries not be empty. It can be any of the following:
// menutitle, id, pagetitle, description, parent, alias, longtitle, introtext
// TO DO: set description to the first non-empty of an array of options
$descriptionField = (!isset($descriptionField)) ? 'description' : "$descriptionField";


// $topdiv [ true | false ]
// Indicates if the top level UL is wrapped by a containing DIV block
$topdiv = (!isset($topdiv)) ? false : ($topdiv==true);

// $topdivClass [ string ]
// CSS Class for DIV wrapping top level UL
$topdivClass = (!isset($topdivClass)) ? 'topdiv' : "$topdivClass";

// $topnavClass [ string ]
// CSS Class for the top-level (root) UL
$topnavClass = (!isset($topnavClass)) ? 'topnav' : "$topnavClass";



// $useCategoryFolders [ true | false ]
// If you want folders without any content to render without a link to be used
// as "category" pages (defaults to true). In order to use Category Folders,
// the template must be set to (blank) or it won't work properly.
$useCategoryFolders = (!isset($useCategoryFolders)) ? true : "$useCategoryFolders";

// $categoryClass [ string ]
// CSS Class for folders with no content (e.g., category folders)
$categoryClass = (!isset($categoryClass)) ? 'category' : "$categoryClass";



// $subdiv [ true | false ]
// Indicates if nested UL's should be wrapped by containing DIV blocks
// This is useful for creating "hover zones"
// (see http://positioniseverything.net/css-dropdowns.html for a demo)
// TO CONSIDER: Setting a subdiv class at all turns on hover DIVs?
$subdiv = (!isset($subdiv)) ? false : ($subdiv==true);

// $subdivClass [ string ]
// CSS Class for DIV blocks wrapping nested UL elements
$subdivClass = (!isset($subdivClass)) ? 'subdiv' : "$subdivClass";



// $orderBy [ string ]
// Document field to sort menu by
$orderBy = (!isset($orderBy)) ? 'menuindex' : "$orderBy";

// $orderDesc [true | false]
// Order results in descending order?  default is false
$orderDesc = (!isset($orderDesc)) ? false : ($orderDesc==true);



// $startFromParent [ true | false ]
// If true, get the first parent of menu. Like an automatic startDoc
// [[DropMenu?parentID]]
$startFromParent = (!isset($startFromParent)) ? false : ($startFromParent==true);

// ###########################################
// End config, the rest takes care of itself #
// ###########################################

if($startFromParent==true)
{
// document id
$cid = $modx->documentObject['id'];
// document parent
$pid = $modx->getParent($cid,1,"id");

$ptarr=array();
$ptarr[]=$cid;
while ($parent=$modx->getPageInfo($pid['id']))
{
$ptarr[]=$parent['id'];
   $pid = $modx->getParent($parent['id'],1,"id");
}
$ptarr = array_reverse($ptarr);
$startDoc=$ptarr[0];
}

$debugMode = false;

// Initialize
$MakeMap = "";
$siteMapRoot = (isset($startDoc)) ? $startDoc : $siteMapRoot;
$maxLevels = (isset($levelLimit)) ? $levelLimit : $maxLevels;
$ie = ($removeNewLines) ? '' : "\n";
//Added by Remon: (undefined variables php notice)
$activeLinkIDs = array();
$subnavClass = '';

// Overcome single use limitation on functions
global $MakeMap_Defined;

if (!isset ($MakeMap_Defined)) {
function filterHidden($var) {
return (!$var['hidemenu']==1);
}
function filterEmpty($var) {
    return (!empty($var));
}
function MakeMap($modx, $listParent, $listLevel, $description, $titleOfLinks, $maxLevels, $inside, $pre, $post, $selfAsLink, $ie, $activeLinkIDs, $topdiv, $topdivClass, $topnavClass, $subdiv, $subdivClass, $subnavClass, $hereClass, $useCategoryFolders, $categoryClass, $showDescription, $descriptionField, $textOfLinks, $orderBy, $orderDesc, $debugMode) {
// Added by Remon. Define this variable _here_ ;-)
$output = '';

$children = $modx->getActiveChildren($listParent, $orderBy, (!$orderDesc) ? 'ASC' : 'DESC', 'id, pagetitle, description, isfolder, parent, alias, longtitle, menutitle, hidemenu, introtext, content_dispo, contentType, type, template');
// filter out the content that is set to be hidden from menu snippets
$children = array_filter($children, "filterHidden");
$numChildren = count($children);

if (is_array($children) && !empty($children)) {

// determine if it's a top category or not
$toplevel = !$inside;

// build the output
$topdivcls = (!empty($topdivClass)) ? ' class="'.$topdivClass.'"' : '';
$topdivblk = ($topdiv) ? "<div$topdivcls>" : '';
$topnavcls = (!empty($topnavClass)) ? ' class="'.$topnavClass.'"' : '';
$subdivcls = (!empty($subdivClass)) ? ' class="'.$subdivClass.'"' : '';
$subdivblk = ($subdiv) ? "<div$subdivcls>$ie" : '';
$subnavcls = (!empty($subnavClass)) ? ' class="'.$subnavClass.'"' : '';
$output = ($toplevel) ? "$topdivblk<ul$topnavcls>$ie" : "$ie$subdivblk<ul$subnavcls>$ie";

//loop through and process subchildren
foreach ($children as $child) {
// figure out if it's a containing category folder or not
$numChildren --;
$isFolder = $child['isfolder'];
    $itsEmpty = ($isFolder && ($child['template'] == '0'));
$itm = "";

                // if menutitle is blank fall back to pagetitle for menu link
                $textOfLinks = (empty($child['menutitle'])) ? 'pagetitle' : "$textOfLinks";

    // If at the top level
if (!$inside)
{
$itm .= ((!$selfAsLink && ($child['id'] == $modx->documentIdentifier)) || ($itsEmpty && $useCategoryFolders)) ?
        $pre.$child[$textOfLinks].$post . (($debugMode) ? ' self|cat' : '') :
        '<a href="[~'.$child['id'].'~]" title="'.$child[$titleOfLinks].'">'.$pre.$child[$textOfLinks].$post.'</a>';
$itm .= ($debugMode) ? ' top' : '';
}

// it's a folder and it's below the top level
elseif ($isFolder && $inside)
{
   
$itm .= ($itsEmpty && $useCategoryFolders) ?
        $pre.$child[$textOfLinks].$post . (($debugMode) ? 'subfolder T': '') :
        '<a href="[~'.$child['id'].'~]" title="'.$child[$titleOfLinks].'">'.$pre.$child[$textOfLinks].$post.'</a>'. (($debugMode) ? ' subfolder F' :'');       
}

// it's a document inside a folder
else
{
$itm .= ($child['alias'] > '0' && !$selfAsLink && ($child['id'] == $modx->documentIdentifier)) ? $child[$textOfLinks] : '<a href="[~'.$child['id'].'~]" title="'.$child[$titleOfLinks].'">'.$child[$textOfLinks].'</a>';
$itm .= ($debugMode) ? ' doc' : '';
}
$itm .= ($debugMode)? "$useCategoryFolders $isFolder $itsEmpty" : '';
   
// loop back through if the doc is a folder and has not reached the max levels
if ($isFolder && (($maxLevels == 0) || ($maxLevels > $listLevel +1))) {
$itm .= MakeMap($modx, $child['id'], $listLevel +1, $description, $titleOfLinks, $maxLevels, true, $pre, $post, $selfAsLink, $ie, $activeLinkIDs, $topdiv, $topdivClass, $topnavClass, $subdiv, $subdivClass, $subnavClass, $hereClass, $useCategoryFolders, $categoryClass, $showDescription, $descriptionField, $textOfLinks, $orderBy, $orderDesc, $debugMode);
}

if ($itm && !$selfAsLink && ($child['id'] == $modx->documentIdentifier)) {
$output .= "    <li class=\"$hereClass". ($numChildren == 0 ? ' last' : '')."\">$itm</li>$ie";
}
elseif ($itm) {
// Added by Remon
// define it here:
$class = '';
if ($numChildren == 0) {
$class = 'last';
}
if (is_array($activeLinkIDs)) {
if (in_array($child['id'], $activeLinkIDs)) {
$class .= ($class ? ' ' : '').$hereClass;
}
}
// it's an empty folder and using Category Folders
if ($useCategoryFolders && $itsEmpty) {
$class .= ($class ? ' ' : '').$categoryClass;
}
if ($class) {
$class = ' class="'.$class.'"';
}

// TO DO: set description to the first non-empty of an array of options
if ($showDescription && (!empty($child['$descriptionField']))) {
    $desc = " &ndash; ".$child['$descriptionField'];
} elseif ($showDescription && (!empty($child['description']))) {
    $desc = ' &ndash; ' . $child['description'];
} elseif ($showDescription && (!empty($child['introtext']))) {
    $desc = ' &ndash; ' . $child['introtext'];
} elseif ($showDescription && (!empty($child['longtitle']))) {
    $desc = ' &ndash; ' . $child['longtitle'];
} else {
    $desc = '';
}

$output .= "<li$class>$itm$desc</li>$ie";
$class = '';
}
}
$output .= "</ul>$ie";
$output .= ($toplevel) ? (($topdiv) ? "</div>$ie" : "") : (($subdiv) ? "</div>$ie" : "");
}
return $output;
}
$MakeMap_Defined = true;
}

$currentID = $modx->documentIdentifier;
$parentID = $currentID;

// find the parent docs of the current "you-are-here" doc
// used in the logic to mark parents as such also
while ($parentID != $siteMapRoot && $parentID != 0) {
$parent = $modx->getParent($parentID, 0);
if ($parent) {
$parentID = $parent['id'];
$activeLinkIDs[] = $parentID;
} else {
$parentID = 0;
}
}

if ($phMode) {
    // output to a [+placeholder+]
    $modx->setPlaceholder($phName, MakeMap($modx, $siteMapRoot, 0, $showDescription, $titleOfLinks, $maxLevels, false, $pre, $post, $selfAsLink, $ie, $activeLinkIDs, $topdiv, $topdivClass, $topnavClass, $subdiv, $subdivClass, $subnavClass, $hereClass, $useCategoryFolders, $categoryClass, $showDescription, $descriptionField, $textOfLinks, $orderBy, $orderDesc, $debugMode));

} else {
    // return the output a "usual"
    return MakeMap($modx, $siteMapRoot, 0, $showDescription, $titleOfLinks, $maxLevels, false, $pre, $post, $selfAsLink, $ie, $activeLinkIDs, $topdiv, $topdivClass, $topnavClass, $subdiv, $subdivClass, $subnavClass, $hereClass, $useCategoryFolders, $categoryClass, $showDescription, $descriptionField, $textOfLinks, $orderBy, $orderDesc, $debugMode);

}

cheers!
Tangent-Warrior Smiley

#15: 16-Aug-2006, 05:58 AM

whitehat
Posts: 29

start of WARNING
You have to overwrite several files.  If you do and things get screwed up, blame yourself for not making copies, don't come whinning to me!
end of WARNING

 Smiley now that is out of the way ...

Ok folks, here is what I've been playing with.  Technically this should be alpha but after playing with this for a bit let's bump it to Beta 1.0  Grin

This is actually a hack that requires jazzing up a bit of the core code in several files.

- You will also need to add 1 field to the site_content table.
- The rest is just upload over previous files.

I've also included some examples for TVs and Chunks to get you going.

 Shocked This is only intended to be an interm solution until the new API for 1.0 comes out.  However, in the meantime this might be something useful.

Cheers!

EDIT:
here is my field for site_content, I just copied it from the dump for my db.  But it should help you add the field.
`lang` char(2) NOT NULL default 'en',

Clarification:
This allows you to do basically the same thing as Susan's cookie code.  Except now it is in the manager and you can change the language declaration as you would if it were published or not .... NOTE .... No quick right-click ability but rather you need to go to the "page settings" section when editing the document.

TO DO:
Figure out how to call 'lang' from the parser to cut down on the sql call that is needed in a TV.
Does anybody know how to do this?

hi Carsten,

Thnx for the prompt answer....

Anyways I have another thing or 2 to ask you.

1. how can I add other languages?
2. Do you have a test site running with this feature so i could take a look on how everything works...

-----------------------------------------------

And if I have other questions I hope you will be able to help me.... i like ur idea better with the multilingual feature just having a bit of trouble to implement it that's all... hehehe

C ya

ah right

P.S.
Quote
Figure out how to call 'lang' from the parser to cut down on the sql call that is needed in a TV.
Does anybody know how to do this?
  Did you solve this???

#16: 17-Aug-2006, 01:37 PM

whitehat
Posts: 29

DropMenuPlus -- is just dropmenu with a small hack. If I remember correctly the hack was something that let's you get the parent of the current category or like that ... jeez, I should remember things like this!

 Shocked

Code:
// ###########################################
// DropMenu                                  #
// ###########################################
// Configurable menu / navigation builder using UL tags
// Offers optional DIV wrappers for top level and nested menus (useful for hover zones)
// as well as configurable classes for the DIV, UL, and LI elements.  It even
// marks ancestors of and the current element with a hereClass (indicating you are here
// and in this area of the site).  Also applies .last CSS class to final LI in each UL.
//
$titleOfLinks, $maxLevels, false, $pre, $post, $selfAsLink, $ie, $activeLinkIDs, $topdiv, $topdivClass, $topnavClass, $subdiv, $subdivClass, $subnavClass, $hereClass, $useCategoryFolders, $categoryClass, $showDescription, $descriptionField, $textOfLinks, $orderBy, $orderDesc, $debugMode);

}

cheers!

I got it running and it looks nice however the parser issue is a bit of a problem ... My WebLogin has stopped functioning I get this message

Code:
« MODx Parse Error »
MODx encountered the following error while attempting to parse the requested resource:
« Execution of a query to the database failed - Unknown column 'sc.lang' in 'field list' »
      SQL: SELECT sc.id,sc.pagetitle,sc.description,sc.alias,sc.lang FROM `modx1`.modx1_site_content sc LEFT JOIN `modx1`.modx1_document_groups dg on dg.document = sc.id WHERE (sc.id=2 AND sc.published=1 AND sc.deleted=0) AND (sc.privateweb=0 OR dg.document_group IN (2)) LIMIT 1
      [Copy SQL to ClipBoard]


Do you have any idea on how ti fix this  Huh

#17: 17-Aug-2006, 06:01 PM

Coding Team

garryn
Posts: 1,391

WWW
Whitehat, I haven't used this mod but I suspect you need to add the lang field to the site_content database table.

As per Carsten's instructions from the first post of this thread:
Quote from: Carsten
here is my field for site_content, I just copied it from the dump for my db.  But it should help you add the field.
`lang` char(2) NOT NULL default 'en',

#18: 3-Dec-2007, 04:53 AM

raynor
Posts: 1

Will this language_hack work with newest MODX version?? I have 0.9.6.1, and made everything (copied files, added lang column to table) but this won't work.

#19: 3-Dec-2007, 04:28 PM

Coding Team

doze
Posts: 4,099

....Boom!

Will this language_hack work with newest MODX version?? I have 0.9.6.1, and made everything (copied files, added lang column to table) but this won't work.
I would guess not, because it overwrites core files and has been done to some previous version.
New MODx wiki! Please help up with documentation efforts! || Old Wiki

"He can have a lollipop any time he wants to. That's what it means to be a programmer."

#20: 24-Jan-2008, 12:16 AM

Moderators
madmage
Posts: 167

Will this language_hack work with newest MODX version?? I have 0.9.6.1, and made everything (copied files, added lang column to table) but this won't work.
I would guess not, because it overwrites core files and has been done to some previous version.

since language hacks (in the wiki you can find a list) are a never ending story, I think that we are all waiting for the 0.9.7 beta version, in order to know where to put our efforts... I also think to have understood that in the 0.9.7 the multi-language site structure can be easily achieved... we'll know soon, I think...
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.