
doolak
Members-
Posts
323 -
Joined
-
Last visited
Everything posted by doolak
-
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Yes, that's right - but as i am using PageTitleLanguage the second language title can be empty and should not be displayed then. So i want to verify first if the users language is different from default language and then display all articles which have a title in that language, somehow like this: if($user->language->name != 'default') { $stories = $page->children("title!= , limit=3"); } -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Is there any possibility to verify if a specific field is empty by using selectors? Something like (as this does not work of course): $stories = $page->children("title='', limit=3"); -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
The current page where the code would have been useful was the newsarticle, so the url was /news/english/lorem-ipsum-dolor-sit I had added <?php echo $page->parent->name ?> to the newsarticle template to verify if the parent is "english" and it was - but nevertheless it did not work for changing the language. But as i described in my previous post at last it was not necessary to verify if "english" is the parent of the article - it was possible to add the url segment "en" at the end. -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Well, right now before i want to try out the different approach with all articles together below /news/ - seperating them just by displaying DE, EN or DE/EN in front of the article list, i managed the other approach to work: There is no need to use something like: if($input->urlSegment1 == 'en') || ($page->parent->name == 'english') { $user->language = $languages->get("en"); } (which did not work anyway) I just had to add the url segment to the article links in the news template like this: <a href='{$story->url}$segment'>{$story->title}</a> The url segment is already defined (for the navigation and other internal links) in the head.inc: if($user->language->name != 'default') $segment = $user->language->name.'/'; else $segment = ''; One just have to enable url segments for the newsarticle template, too... So as far i can see this works - the only drawbacks i found until now are: 1. If you are on the newspage of one language, where just those articles are listed and you choose one article to read more - the article is shown now correctly but if you change the language through the language switcher, the article is still displayed. 2. The "title" thing i described above - but if i understood apeisa right one could the normal title field plus a language alternate field instead of the multilanguage title field. Nevertheless i will try out the other approach - having all newsarticles under /news/ - this would have some advantages like described in my previous post - and as you will usually would retreive a 404 error if the article is not existant in both languages when switching the language while watching an article, one could add a redirection to the newspage in this case. I just have to figure out how one could handle it to display DE, EN or DE/EN in front of the articles in the administration... -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Hm, no - this does not work either. But i just recognized another point which also speaks against using the subpages /english/ and /deutsch/ for the different newsarticles: I am using the pagetitle field with the type "PageTitleLanguage" - so on every page the optional second language is displayed. This would be a little confusing if i am using two seperate areas for english newsarticles and german newsarticles, because there would be no english title needed. If i see it right, there is no possibility to add two types of the pagetitle to use PageTitleLanguage on some pages and just PageTitle on others. So maybe it will be the best solution to have all newsarticles simple under /news/ This would make it possible to have one newsarticle in both languages - or just in one of them - simply by ading values to the multilanguage fields or leaving them empty. Would just be great if one could display somehow in the pagelist if this article is english or german - or both... I will try if that could work... -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Yes, you are right - i just discovered this too and now I am trying this: if($input->urlSegment1 == 'en') || ($page->parent->name == 'english') { $user->language = $languages->get("en"); } It just seems that nevertheless i have to include the $segment part in the news template - will try it out and let you know if it works. -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
@ryan: You have used if($page->name == 'en') instead of if(($input->urlSegment1 == 'en') - was this accidentally or should that work too? -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Now i have tried this: if(($input->urlSegment1 == 'en') || ($input->urlSegment1 == 'english')) { $user->language = $languages->get("en"); } ... but that does not work. The URL is: /news/english/lorem-ipsum-dolor-sit-amet/ so this should be the first URL segment, but it does not keep the language. Any idea why this does not work? I have tried the possibility with session, but then the language is not more changed when the user klicks the language switcher (Maybe the session should be destroyed then, but i don't know how to manage this...). -
Seperate news for each language - some problems...
doolak replied to doolak's topic in Multi-Language Support
Yes, I had just enabled page numbers for the template which is used for the pages /deutsch/ and /english/ - i had to enable it for the page /news/ - so pagination works fine now. I have this enabled, so for the general newspage /news/ this works fine - the default language shows /news/ and the english version shows /news/en/ It's just the problem that i have used those subpages for dividing in english and german newsarticles - the url of the article will be something like this: /news/deutsch/lorem-ipsum-dolor-sit or /news/english/lorem-ipsum - so maybe i have to add the url segment to the news-template to generate language-specific urls like /news/en/english - or i just have to add the url segment "english" to this code: <?php if($input->urlSegment1 == 'en') { $user->language = $languages->get("en"); } ?> I have to try this out... -
Hi there, i am trying to display seperate news for two languages - and my attempt to to this is as follows: To render the multilanguage navigation i use the following code: <?php if($user->language->name != 'default') $segment = $user->language->name.'/'; else $segment = ''; ?> So i have just one news-page "News", which is displayed as /news/ and news/en/ (German is the default language). That's why i had to use "english" in the page tree, because otherwise i am getting a 404 error when trying to switch to the english newspage. The articles could be directly under this page, but i would like to have them sorted in english and german - so I am using this pagetree: /news/ deutsch/ <= page ID 1131 newsarticle newsarticle newsarticle english/ <= page ID 1132 newsarticle newsarticle In the news template i use the following code for the selection of the different news: if($user->language->name == 'default') { $news = $pages->get("id=1131"); $stories = $news->children("limit=3"); } else { $news = $pages->get("id=1132"); $stories = $news->children("limit=3"); } To cycle through the stories as follows: foreach($stories as $story) { // markup for displaying news... } // output pagination links: echo $stories->renderPager(array( 'nextItemLabel' => "»", 'previousItemLabel' => "«", )); So far it works fine - the different news are listed on the two different language versions of the news page (/news/ and /news/de/) - the articles are shown under /news/ and /news/de/ - but now i have two problems: 1. As the news articles are displayed under /news/deutsch/ and news/english/ the navigation always switches back to the default language, i guess because the url segment /en/ is missing then. 2. Another problem is the fact that the pagination does not work in this scenario. It is shown correctly but it does not work - the next page does not show up when using the navigation. I can imagine that i have to define "baseUrl" but i cannot get it to work. Maybe there is a much better solution for displaying seperate news for each language - if you have an idea, i would appreciate your help. If my approach is ok in general, it would be great if you help me to fix the two problems i mentioned above.
-
Exactly. agree i.do do.i thank y.ou so much
-
Perfect! Works like a charm. And imagine the code without the API if you have a lot of exclusions like this: if ($page->find('template!=template1|template2|template3|template4, name=Peter|Paul|Mary, age>21) { // Do your thing } It would be a quite long repetition of if (($page->template!=news) && ($page->template !=news_article)) && ...
-
Uhh, i tried $page->matches, but not as you described it with !$page - that looks good, i will have a try!
-
LOL - yes, and using template1|template2 works like OR - so that's why i tried my first described solution. But it works fine as it is now - so no need to spend too much time with this - it's just as you said, PW is full of possibilities and it just does not go out of my mind because i know there is a very simple solution somewhere in the API... ;-)
-
Yes, that does not work - same as my attemps above. But i guess there is just a little mistake in thinking somehow...
-
I just thought that there is a PW-specific solution for this which may be suitable e.g. if you have a lot of selectors which you want to exclude...
-
Well, i guess i just have to make a break and catch some sleep... I want to include a file just if the current page does not use specific templates, but i cannot get it to work with PW selectors somehow in the way like this: $select = $pages->find("template=news|news_article"); if ($page->id != $select) { include ("./recent_news.inc"); } or maybe: if ($page->template != news|news_article) { include ("./recent_news.inc"); } I know i am running somehow in the wrong direction, so for now i am using this: if (($page->template!=news) and ($page->template !=news_article)) { include ("./recent_news.inc"); } ... which works, but it does not make me happy, because i know there has to be a different approach. Would be so great if you please push me in the right direction...
-
Thanks, Soma! Works fine now - and as i see you already changed the documentation to 'item_current_tpl' and 'xitem_current_tpl'. Well, i guess there are not soooo many reasons to use the inner templates - most people will use CSS to change the active element which is added through 'current_class' - but for the multilanguage navigation it does a great job now to add the url segment for the active item. Thanks for your help and for that great module!
-
Hello again... I added some code to the 'item_active_tpl' - but somehow this is not recognized and the output for the active items does not change. In this case it's the url segment for a multilanguage site: 'item_active_tpl' => '<a href="{url}'.$segment.'">{title}</a>', // template string for the active inner items. Has anybody else encountered that problem or could someone maybe try to reproduce it? I am using the latest dev branch version of PW - but i cannot say if the problem is version related, as i did not tried this in an earlier version of PW.
-
I had the same issue right now for the first time. It's my own server, so there are no restrictions through a provider. I have already installed several PW sites on this server and never had that problem before. The error console says: Failed to load resource: the server responded with a status of 500 (Internal Server Error) JqueryCore.js:2SyntaxError: JSON Parse error: Unexpected identifier "Error" I checked if maybe the storage space was full, but that was not the fact. The main PHP version on the server is still 5.2.17 - i have decided to install PHP 5.3 additional because there are some websites running on my server who are not compatible to > PHP 5.2 On the webspace where i encountered that problem i had chosen PHP 5.3 through htaccess: AddHandler application/x-httpd-php53 .php When i remove that line so PHP 5.2.17 is used for this webspace again, everything works fine with the upload. I am using the latest dev branch of PW. So in this case it seems to be a PHP version problem - but of course it's strange that the problem appears under the additional installed 5.3, not under 5.2.17
-
Multi-lingual sites with the Processwire CMS
doolak replied to ryan's topic in Multi-Language Support
So this thread was started before there was the Language Support with multilanguage fields was added to the core... I wonder what you would recommend now for a smaller site - still the multi-tree approach? I can imagine just one case which speaks against the use of the multilanguage-fields: If there are some pages which should just be displayed in one language version. But it should be possible to exclude them somehow in the template and redirect to the homepage then - so i personally tend to go for the multi-language fields. -
Yes, that's right - it does not show the success message anymore then. If i leave the comment form visible (not hide it with CSS) and use the code as follows it works: $(document).ready(function() { var $input = "<input type='hidden' name='security_field' value='1' />"; $("#CommentForm form").append($input); }); BTW: How does that security field works? I guess it should work as a Honeypot fields, right? I just wondered because there is a value set for that field - and shouldn't such a honeypot field be a normal text field, just hidden cia CSS? I tried to find out how it is handled in the Commentform.php and i found this part: if($key = $this->options['requireSecurityField']) { if(empty($data[$key])) return false; } Now i am much more confused ...
-
Spam protection alternatives for Comments Module
doolak replied to doolak's topic in Wishlist & Roadmap
After i now found "requireSecurityField" in the form settings of the Comments Module and searched how to implement this, i found this thread: I guess this will be a sufficient alternative to Akismet for the moment... -
Spam protection alternatives for Comments Module
doolak replied to doolak's topic in Wishlist & Roadmap
LOL - great! But maybe not the best choice for a business like e.g. a funeral home... -
As Akismet is not free for business websites it would be great to have the option to add alternative spam protections, similar maybe to those who are provided in the Form Builder.