dlen
Members-
Posts
35 -
Joined
-
Last visited
Profile Information
-
Gender
Male
-
Location
Berlin
-
Interests
Meditation, Climate Change
Recent Profile Visitors
2,086 profile views
dlen's Achievements
Jr. Member (3/6)
8
Reputation
-
Dear forists, I wanted to echo some strings with a simple echo "bla bla"; statement from within a page template. While this works in _main.php and _init.php, I did not get it to work from a page php-template, like "gallery-page.php". There is no error message. Everything else works as expected. This is not an important issue, but I'd like to find some explanation for this, just to not have think about it longer. Thx for any productive hint...
-
Many thx. Wouldn't have thought so, but downgrading PHP to 7.4 fixed the problem.
-
Same with me. downgrade to 7.4.13 and template change works again. Who would have thought that?
-
When I create a new page, i can choose between a couple of templates. but after creation, when i go to the - settings/template dropdown, there is only one template to choose from: The respective template setting is in default, i.e. allows to change the template. Any hints welcome!
-
Hi, got the same problem. Although there is no deactivation of plugins now, but activation check boxes: I just see no effect... - any hint appreciated.
-
Thx. I used another solution, which does the job. foreach($languages as $language) { if(!$page->viewable($language)) continue; $url = $page->localHttpUrl($language); $hreflang = $homepage->getLanguageValue($language, 'name'); if ($hreflang == 'home') $hreflang = 'x-Default'; echo "\n\t<link rel='alternate' hreflang='$hreflang' href='$url' />"; The code example stems from the freshly installed multilanguage demo site.
- 16 replies
-
- 2
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
- 16 replies
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
Sure. It is the original code fresh after installation, in _main.php: <?php // handle output of 'hreflang' link tags for multi-language // this is good to do for SEO in helping search engines understand // what languages your site is presented in foreach($languages as $language) { // if this page is not viewable in the language, skip it if(!$page->viewable($language)) continue; // get the http URL for this page in the given language $url = $page->localHttpUrl($language); // hreflang code for language uses language name from homepage $hreflang = $homepage->getLanguageValue($language, 'name'); // output the <link> tag: note that this assumes your language names are the same as required by hreflang. echo "\n\t<link rel='alternate' hreflang='$hreflang' href='$url' />"; } ?> I could live with that for the time being, as it is only an SEO issue, but of course it would be nice having it working.
- 16 replies
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
Brilliant. Now the menu works as advertized and the page URLs reflect the respective language, i.e. '/' in the case of German, '/en/' in the case of English. Only the hreflang attributes in the header links are causing some headscatching: <link rel='alternate' hreflang='home' href='http://butoh-tanz.de/pw/' /> <link rel='alternate' hreflang='en' href='http://butoh-tanz.de/pw/en/' /> The second looks o.k., while the first I do not understand. Shouldn't it be 'de'?
- 16 replies
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
A brilliant tutorial. Did this with the minimal multilanguage site offered for installation. Default language is now German as wanted. Then I uninstalled and reinstalled English. The main menu 'home' link is pointing to 'pw/<german homepage>, which is as it should be, while the 'about' link points to 'pw/en/about', which should be 'pw/about'. In the page settings of the 'about' page the hierarchy of the DE page is 'en/about', while the hierarchy string for the EN page is '/about'. See attached screenshot. The link of the latter is pointing to http://butoh-tanz.de/pw/about/ but clicking it we end up on http://butoh-tanz.de/pw/en/about/. The language menu does show both 'de' and 'en' links, as desired. But the 'en' link points to '/pw' (the processwire root, one level below site root, as this is experimental) instead of 'pw/en/'. Clicking on any link in the language menu does not change anything on any page. The 'home' page stays German while all other pages stay English. So obviously this method does not achieve the goal to completely reverse the language hierarchy, with all German pages having a 'pw/<pagename>' URL and all English pages having a 'pw/en/<pagename>' URL. This is absolutely no critique, as you wrote your tutorial for a single language site. I just would be thankful for a hint how to achieve this URL string reversal.
- 16 replies
-
- tutorial
- default language
-
(and 4 more)
Tagged with:
-
I had a vicious [] operator not supported for strings (line 133 ….) - problem, after casually upgrading the module. I could not access the backend anymore. I had PHP 5.6 running and tried out 7.0 and 7.1 without success. Then in my desperation I resolved to fiddling the module code (I have pretty weak PHP knowledge). In simplecontactform.module, line 133 , I changed foreach (self::$additionalFields as $f) $allFieldsExtended[] = $f; to foreach (self::$additionalFields as $f) $allFieldsExtended = (array)$f; and at least I was again able to keep on working. But I don't know, whether the module is working fine now, as I have my contact form without module. Might help some poor guy one day...
-
With this script a strange problem appears: (solution below) When loading first, i.e. with $session->secondvisit nonexistent and setting $user->language to 'de' (in my case), the menu is correctly shown in german the language menu correctly shows the german link as active but the content is shown in the english version the url in the address field does not show the /de characteristic for the german content tree One remark, of which i do not know the importance: the site is redirected to a subdirectory. The URL ist http://agustin-rivas.com. If someone has seen this before and can give a clue, i'll be grateful. -------------------------------------------------------------------------------------------------------- solution --------------------------------------------------------------------------------------------------------- It was a timing problem. I had put the above function into the main template php file, which is executed a f t e r the php files for the different page templates. So the content variables were filled with the $user->language still not correctly set. Moving the function code to the _init.php file, which is executed b e f o r e the page template php files, solved the problem. Took me 2 hrs to figure it out believe it or not...
-
You are probably right, may be I (or somebody else) adds something to it. For the time beeing i don't see i have the resources for it.
-
Hi there, I got a template with a field of type "file" in it. If the client did load a file up, a download link is shown - otherwise nothing. The templates name is "termin" and the fields name is "termininfo". middlecontent is some string that collects the HTML. My method to find out, whether a file has been uploaded, is the following: if ($termin->termininfo) $middlecontent .= "<a href='{$termin->termininfo->url}' target='_blank'>INFO</a>\n"; else $middlecontent .= "<a class='hidden'></a>"; My question is, why in some cases, which i cannot really reproduce, the condition $termin->termininfo is false, although a file has been uploaded. This occurs only in a fresh dataset, where no file has been uploaded previously. Maybe there is a better way to check for the existence of the uploaded file. cheers...
-
An updated version with some more features /** * A recursive menu containing home. * If no root page is given, site root will be taken. * If and only if the second parameter is given, only pages will be included, that have a custom field of type "checkbox", * and the latter has to be checked. This field is the parameter to be given. Example with field "in_main_menu": * * selectiveMenu(null, $fields->in_main_menu); * * All submenu <ul>s get class "submenu". * All <li>s in the direttissima upwards of the page shown - except home - get the class "current". * All menu items, that have the template name 'no_content' do not have a link to their content, but act merely as switches * to their subpages. This template must have also the selector field, if the parameter is given. * * Intended to be used without arguments, i.e. "selectiveMenu();" , i.e. always starting with site root. * * @param Page root page of the menu * @param Field menu_selector_field pages with this "checkbox" field in their template set to "checked" are represented * @param string menu_id The id the outermost ul - tag gets. * @return string */ function selectiveMenu(Page $root = null, Field $menu_selector_field = null, $menu_id = null) { $shownPage = wire('page'); if(is_null($root)) $root = wire('pages')->get('/'); $level = count($root->parents); $ul_class_string = (($level > 0) ? "class='submenu'" : ""); $ul_id_string = ($menu_id ? "id='$menu_id'" : ""); $out = "\n<ul {$ul_class_string} {$ul_id_string}>"; $parents = $shownPage->parents; $items = $root->children; if ($level == 0) $items->prepend($root); foreach( $items as $item) { if ($item->$menu_selector_field || !$menu_selector_field) { $s = ''; $li_class_string = ( ( $parents->has($item) && $item !== $root ) || $item === $shownPage ? "class='current'" : "" ); if($item->numChildren(true) && $item !== $root) { $s = str_replace("\n", "\n\t\t", selectiveMenu($item, $menu_selector_field)); } $href_attr = ( $item == $root || $item->template->name != 'no_content' ? "href='$item->url'" : "" ); $out .= "\n\t<li {$li_class_string}>\n\t\t<a $href_attr>{$item->title}</a>$s\n\t</li>"; } } $out .= "\n</ul>"; return $out; }
- 1 reply
-
- navigation
- recursive
-
(and 1 more)
Tagged with: