1
ghia
XLanguage and WF-links
  • 2009/5/21 15:03

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


WF-Links has an overview of its links with a shortened description text. When you use XLanguage and the language tags, this can lead to disastrous results, because the snipping does not take into account the boundaries of these tags.
Due to the unbalanced tags XLanguage will remove various other parts of your sites page.
The problem starts with /modules/wflinks/templates/wflinks_linkload.html which contains:
<div align="justify"><b><{$smarty.const._MD_WFL_DESCRIPTIONC}></b><br /> 
<{
$link.description|truncate:256}></div>
So, after 256 characters the text is truncated.

One solution would be to remove the modifier, but this would then always display the whole text and makes the 'read in detail' link useless.

We want a teaser or introduction, followed by a main part. eg
[lang1]intro[/lang1][lang2]intro[/lang2][lang1]main[/lang1][lang2]main[/lang2]

The intro is used in the overview and the complete text (intro and main) is used in the detail view of the link.
Therefore this rough Smarty hack:
<div align="justify"><b><{$smarty.const._MD_WFL_DESCRIPTIONC}></b><br /> 
<{
php}>
if (
$len maxstrpos($this->_tpl_vars['link']['description'],'[/nl]'), strpos($this->_tpl_vars['link']['description'],'[/en]'), strpos($this->_tpl_vars['link']['description'],'[/fr]'), strpos($this->_tpl_vars['link']['description'],'[/de]'))) 

 
$this->assign('shortdescription'substr($this->_tpl_vars['link']['description'], 0$len+5).' ...'); 

else

 
$this->assign('shortdescription'substr($this->_tpl_vars['link']['description'], 0256).' ...');
}
<{/
php}>
<{
$shortdescription}><{* $link.description|truncate:256 *}></div>
What it does: it looks up the positions of the language end tags (eg nl fr de en) and uses the length of the last tag for having the complete block with all intro's in the overview list. As fallback is provided that when no language tags are present the previous 256 limit is used to truncate the text.
It expects:
- that all your tags are used in the link description or none.
- that the intro parts (any language order) come first.
- only single tags are used and not the multi eg [lang1|lang2]

2
McDonald
Re: XLanguage and WF-links
  • 2009/5/21 17:10

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


You're probably using an older version of WF-Links.

Open include/linkload.php and find the line(s) where the description is assigned. It probably looks like this:
if (defined("ICMS_VERSION_NAME")) {
  
$link['description'] = wfl_substr($link_arr['description'], 0$xoopsModuleConfig['totalchars'],'...');
} else {
  
$link['description'] = $wfmyts -> displayTarea$link_arr['description'], 1111);
}

Replace it with:
$link['description'] = xoops_substr($link_arr['description'], 0$xoopsModuleConfig['totalchars'],'...');

In wflinks_linkloadinfo.html replace
<{$link.description|truncate:256}>

with
<{$link.description}>

3
ghia
Re: XLanguage and WF-links
  • 2009/5/21 17:37

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


It is indeed not the latest version , but the point for the hack is to prevent cutting in the middle of language tags and to have text in all languages for the brief description.

I don't think your code snippets manage that.

4
Catzwolf
Re: XLanguage and WF-links
  • 2009/5/21 19:33

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Firstly, I think the whole problem is trying to fit a square peg in a round hole with this.

There are many modules that use this method of shortening text to a certain length and I don't think that this is due to the short comings of WF-Links but due to the nature of Xlanguage. The whole design and implementation of multi-language in this method, will cause these problems with any module and will only be fixed with a more global core approach to multi-language.

So how to fix this, not sure there is a real fix due to the 'hackiness' that you have implied with your own solution. I don't think that in reality that it's WF-Links job to check for this or provide a solution and I don't see how this could be achieved either.




5
McDonald
Re: XLanguage and WF-links
  • 2009/5/21 20:02

  • McDonald

  • Home away from home

  • Posts: 1072

  • Since: 2005/8/15


The file include/functions.php contains the function wfl_substr which should overcome this. I'm not sure if this function works with XOOPS there it was written for ICMS.

6
ghia
Re: XLanguage and WF-links
  • 2009/5/21 20:10

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


It is not a problem of WF-links.
And XLanguage makes problems for other modules that shorten content, but as you said that's the nature of XLanguage and for the time being, if we want a full multilingual site with XOOPS, there is not much else.
All this thread is for, is to show others that might run in the same troubles my (maybe not so good), but functioning solution to the truncating problem.

A better solution would be in PHP, where the xoops_substr test if XLanguage is present/active and then uses the functions of the XLanguage module to clear out the unused languages in the block of content (eg link description) and then the resulting text can be truncated as usual.
(All modules like WF-links, News, etc should then have to use this function for truncating)

Quote:
The file include/functions.php contains the function wfl_substr which should overcome this. I'm not sure if this function works with XOOPS there it was written for ICMS.
Yes, it seems to take in effect the language tags. It seems specific for ICMS, but it can be a good start for a PHP implementation in XOOPS with XLanguage.

7
Mamba
Re: XLanguage and WF-links
  • 2009/5/21 21:05

  • Mamba

  • Moderator

  • Posts: 11204

  • Since: 2004/4/23


Quote:
if we want a full multilingual site with XOOPS, there is not much else.

Did you try the The Easiest Multi-Language Hack (EMLH) 1.31
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

8
Catzwolf
Re: XLanguage and WF-links
  • 2009/5/21 21:14

  • Catzwolf

  • Home away from home

  • Posts: 1392

  • Since: 2007/9/30


Quote:

Mamba wrote:
Quote:
if we want a full multilingual site with XOOPS, there is not much else.

Did you try the The Easiest Multi-Language Hack (EMLH) 1.31


Uses the same principle as the latter and therefore has the same issues.

9
ghia
Re: XLanguage and WF-links
  • 2009/5/21 21:24

  • ghia

  • Community Support Member

  • Posts: 4953

  • Since: 2008/7/3 1


Indeed.
And XLanguage has also the advantage of switching the module language (same effect as with general preferences).

Login

Username:
Password:

Lost Password? Register now!

Who's Online

60 user(s) are online (48 user(s) are browsing Support Forums)


Members: 2


Guests: 58


Mamba, heyula,

more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits