Jump to content

kixe

Members
  • Posts

    803
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by kixe

  1. The url exists even if the language isn't active, but it will return a 404 in this case. You have 2 options to solve your problem: modify your code of your navigation, check the language specific status of the page you want to add to the nav. via template. disable multilanguage support under advanced tab in your single language templates. Code for 1. option: $nav = '<ul>'; foreach ($pages->find('parent=1,include=all,status<1024') as $p) { $url = ($user->language->isDefault() == false && $p->{"status{$user->language->id}"} == 0)? $p->localUrl($languages->getDefault()):$p->url; $nav .= "<li><a href='$url'>$p->title</a></li>"; } $nav .= '</ul>';
  2. I didn't know that you need to extend the WireData class. Extending ProcessTemplate this shouldn't happen.
  3. Try this: public function init() { $this->addHookAfter("ProcessTemplate::buildEditForm", $this, "appendFieldToForm"); $this->addHookBefore("ProcessTemplate::executeSave", function($event) { $event->object->template->set('seo_rules', $this->input->post->seo_rules); $languages = $this->wire('languages'); if($languages) { foreach($languages as $language) { $event->object->template->set('seo_rules'.$language->id, $this->input->post->{"seo_rules__$language->id"}); } } }); } public function appendFieldToForm(HookEvent $event) { $languages = $this->wire('languages'); $template = $event->arguments[0]; $form = $event->return; $field = $this->modules->get("InputfieldText"); $field->attr('id+name', 'seo_rules'); $field->attr('value', $template->seo_rules); if($languages) { $field->useLanguages = true; foreach($languages as $language) $field->set('value' . $language->id, $template->get('seo_rules' . $language->id)); } $field->label = $this->_('Seo rule'); $field->description = $this->_('If you want to add a custom rule to MarkupSEO'); // Description for field tags $field->notes = $this->_('To define a variable use {title} syntax'); $form->insertAfter($field, $form->tags); $event->return = $form; }
  4. From the first view your code has some issues: 1. The variable $template is not defined. This one should work: $template = $event->argument[0]; 2. You cannot use InputfieldTextLanguage here. You need to use InputfieldText and than loop the languages. $languages = $this->wire('languages'); $field->attr('value', $template->seo_rules); if($languages) { $field->useLanguages = true; foreach($languages as $language) $field->set('value' . $language->id, $template->get('seo_rules' . $language->id)); } 3. As far as I know 2nd Argument of function insertAfter() should be an object of type Inputfield you are using a string. 4. in the end you need to overwrite $event->return otherwise there is no change. If I find some time I will have a deeper look.
  5. @nabo Welcome to the forum. You need to hook in ProcessTemplate::buildEditForm. More about hooks: http://processwire.com/api/hooks/
  6. The Function wireClassExists() is described as follows: ProcessWire namespace aware version of PHP's class_exists() function The function returns the expected value, without a defined namespace <?php class bar extends Roles { } // namespace aware function var_dump(wireClassExists('bar')); // return false var_dump(wireClassExists('\bar')); // return true // not namespace aware function var_dump(class_exists('bar')); // return true and with defined namespace <?php namespace ProcessWire; class bar extends Roles { } // namespace aware function var_dump(wireClassExists('bar')); // return true var_dump(wireClassExists('\bar')); // return false // not namespace aware function var_dump(class_exists('bar')); // return false
  7. Maybe my module Cronjob Database Backup could help. This module has an option to delete all backups except a predefined number of last backups to keep (via Module settings). Also some other useful options. Try out, feedback welcome. http://modules.processwire.com/modules/cronjob-database-backup/
  8. Nothing special. Just to use session based message. Again something to complain about. Sorry for this Good to have the option to limit the cookie consent to a special path/ tree. But in this case the banner shouldn't be shown for pages not residing under this tree. It would also be nice to store the page id and not the path, to stay multilanguage compatible and to avoid problems if the page name has been changed. A page-field (instead of text) would be the simplest solution here.
  9. Thanks for the quick implementation. Again 2 small remarks. 1. Cookie Expire The field description and the behaviour of the property 'cookieExpire' doesn't match. I got this after install: You should either change the description to something like 'Cookie expire date (Unix Timestamp)' or add time() later and not directly to the property like: setcookie($this->cookieName, 1, time() + $this->cookieExpire, $this->cookiePath, $this->cookieDomain, $this->cookieSSL, $this->cookieHttp); 2. About Version Numbering Your last version was: 0.1.51 Your update version is 0.1.6. PW detects an older version in this case and ask if I want to overwrite the newer module version by an older one. PW handles only 2 subversion levels. A version number like 0.1.5.1 is not possible in PW. So your new version number should be 0.1.52 or 0.2.0. It doesn't really hurt. Just to know ...
  10. Keeping an eye on flexible filtering and output options I would store all the cars under the same parent and control the output via urlSegments. In this case an integer field is good and enough. Output path to list all cars /cars/ Output path to list cars builded in 1976, whereas urlSegment1 = filter-key and urlSegment2 = filter-value /cars/build/1976/ Read more about urlSegments https://processwire.com/api/variables/input/
  11. @keksmampfer Welcome to the forum. You are using wrong syntax for PHP for() which is: for (expr1; expr2; expr3) Assuming you are talking about foreach(). Using foreach, your code should work within a module too. If you would post the context or function from where you call this loop within the modules class, it would be easier to help.
  12. @Can Good to point this out. But already with a simple contactform you need cookies. I stay with your module as default. Edit: I ended up with a combination. Added the following code to my config.php /** * if we would use cookies only for the admin area * */ $config->sessionAllow = function($session) { // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // user accepted cookies due to EU law (Module MarkupCookieConsent) if(!empty($_COOKIE['eu-cookie'])) return true; // otherwise disallow session return false; }; Small request: I would like to set a more specific target to the privacy policy page including an url fragment string like /privacy-policy/#cookies Would be nice to have an inputfield to add this to the url of the target page. Actually don't need this now but having an option to define an external page would be nice too. I don't really get the usage of Link Target -> Custom Selector Is it just to get the target frame by name according to the html attribute, or is it a kind of PW selector?
  13. @Robin S You are right. Sorry for the quick shot. Next time I read your post better.
  14. Great. I use this to trigger 404 by an empty field in a specific language // 404 trigger --------------------------/ $fields->get(133)->langBlankInherit = 1; $langTrigger = $page->getLanguageValue($currLang->id, 'body'); if (!$langTrigger) throw new Wire404Exception();
  15. @Robin S Your code will not work the naming format of a repeater page is based on microtime. You maybe talking about the parent. The format is 'for-page-1234' Unfortunately FILTER_SANITIZE_NUMBER_INT will not remove the dashes (minus). To get the page where this repeater item lives you can go this way: $mypage = $pages->get('id='.ltrim(strrchr($page->parent->name ,'-'),'-')); // the page where this repeater item lives
  16. @Robin S Thanks for he help. I am a bit too busy to answer in time. Agreed. If I'll find some time, I will make an update. Apart from this I hope module is doing its job ...
  17. I am currently working on a basic module to provide several user interfaces for comfortable page listing and editing apart from the page tree. Everything is working as expected, but its not possible to enable language support for the name field under the settings tab in the editor. In the core ProcessPageType.module is in use to provide listing and editing users, roles, permissions and languages. All these 'pages' have a name field in default language only. How can I force ProcessPageType module to provide the multilanguage page name field under the settings tab? Thanks for any ideas.
  18. Hi Can, thank you for this great module. Would be great to have the 'policy link text' in multilanguage too.
  19. @Lance O. If you use PW Version 3.0.22 you should make an update to the last available version. This should solve your problems. The date of your post looks a bit '3.0.22ish' @Hani Thanks for this great module. It is working as expected. Even in the latest 3.0.x I made the inputfield selectable to make all subclasses of 'InputfieldSelect' available. FieldTypeTemplates.zip
  20. Thanks for the hint. Everything is working as expected again in PW 3.0.24.
  21. The module is not compatible with PW 3.0.22. Please check. Module configuration is not loaded properly. If I can figure out details I will post here.
  22. PW 3.0.x is very close to stable. I use it since 3.0.8 without any problems.
  23. $page->getLanguages() was introduced in PW 3.0.21 (2.8.21). Please check your ProcessWire Version.
  24. Since PW 3.0.21 (2.8.21) you can use: echo count($page->getLanguages()); in your case: if (count($page->getLanguages()) > 1) { $markup = ''; foreach($page->getLanguages() as $language) { if ($language->isCurrent()) continue; $markup .= "<li><a href='".$page->localUrl($language)."'>".$language->getLanguageValue($language, 'title')."</a></li>"; } echo "<ul>$markup</ul>"; }
  25. Wire::message() Wire::warning() Wire::error() /** * Record an informational or “success” message in the system-wide notices. * * This method automatically identifies the message as coming from this class. * * ~~~~~ * $this->message("This is the notice text"); * $this->message("This notice is also logged", true); * $this->message("This notice is only shown in debug mode", Notice::debug); * $this->message("This notice allows <em>markup</em>", Notice::allowMarkup); * $this->message("Notice using multiple flags", Notice::debug | Notice::logOnly); * ~~~~~ * * #pw-group-notices * * @param string|array|Wire $text Text to include in the notice * @param int|bool $flags Optional flags to alter default behavior: * - `Notice::debug` (constant): Indicates notice should only be shown when debug mode is active. * - `Notice::log` (constant): Indicates notice should also be logged. * - `Notice::logOnly` (constant): Indicates notice should only be logged. * - `Notice::allowMarkup` (constant): Indicates notice should allow the use of HTML markup tags. * - `true` (boolean): Shortcut for the `Notice::log` constant. * @return $this * @see Wire::messages(), Wire::warning(), Wire::error() * */ have a look in Wire.php
×
×
  • Create New...