Jump to content

gebeer

Members
  • Posts

    1,554
  • Joined

  • Last visited

  • Days Won

    48

Everything posted by gebeer

  1. Thank you for your looking into this and for your input. I still need multilingual for each country because there is a core content section that is the same for all countries. And that core content needs to be available in 4 or more languages in each country. And, honestly, I am a bit scared of manipulating the DB manually. I might break the whole site. I will experiment with option 2 from my first post and post my findings here. That is, writing a script that swaps language content over. E.g. English content gets swapped with German content. Then just change language titles and URLs on homepage.
  2. I know this has been discussed in detail over the years and I read everything I could find about it in the forum. And still, no (straightforward) solution to my scenario. My situation: I set up a multilingual events directory site were instructors can sign in and manage their events. There is a core content area which is available in 4 languages. Instructors post their personal info and their events in only one language, but field labels need to be multilanguage. Therefore I need multilanguage page names and fields for them, too. The site has been running on Joomla/Seblod for 3 years already. I am currently in the process of porting it to PW. Once this is done, a skeleton of the site will be rolled out in different EU countries, so instructors in those countries have their own PW install to manage events for their country. Of course, the default language needs to be a different one in each country. And this is where my problem lies. I have the multilanguage setup with Language Support Page Names module and am working with multi-language fields in a 2.6.23 install. In the original project, the default language is English. Now I need to make a copy of the site that has German as default. Solutions that I am aware of are: 1. do a redirect for the default language homepage. For the frontend this is fine except for the /de/ appended to the home page. In the backend, the German users have language German. But German is not the default language. So when a user creates a new event, they will be presented with the German tab open for multi-language fields. When they fill in the title (PageTitleLanguage) and hit save, they get an error "Required value missing" for the title field. Because they only fill in the german title and the default (english) title is still empty, hence the error. So this is actually not a solution. 2. switch the values for multi-language fields by script (like proposed here) and rename the default's language title to "German" and adjust the URLs in the page names of the home page. While this is doable, it requires quite some effort as I will have to do this for every country. In Joomla/Seblod I can just change the default language with one click in the backend. And I am very much missing this feature in PW Finally, my question: Is there any way other than solution 2 to handle the situation? Maybe I missed some new features or maybe someone has come up with a way to truly change the default language programmatically. Thanks for reading through all of this. Any help would be very much appreciated.
  3. Just to confirm, proposed module from this thread is working fine for me in a 2.6.23 install.
  4. Thank you @Soma and @LostKobrakai That did the trick Got confused by the cheatsheet saying:
  5. Hello, I have a multilanguage page, running on PW 2.6.23. This is a conversion of a german Joomla site which already has active members. It is a requirement to have a specific format for user names which are generated from the Full Name of a user: "Test Üser" should become "Test_Ueser_1552", where 1552 is the user id. (note conversion of Umlaut Ü to Ue) I have changed and added Umlaut conversion in the InputfieldPageName settings to read: æ=ae å=a ä=ae Ä=ae ß=ss ö=oe Ö=oe ü=ue Ü=ue ... I have created a "member" template based on the user template, following instructions here. This is all working fine and I can create member users. My member template has a text field "fullname". Now I have written a small module to create my custom user name format from the fullname field: public function init() { $this->pages->addHookBefore('Pages::saveReady', $this, 'renameMember'); } protected function renameMember($event) { $page = $event->arguments[0]; if($page->template != 'member') return; $sanitizer = wire('sanitizer'); if($page->isChanged('fullname') && !empty($page->fullname)) { $name = $page->fullname; $newName = str_replace(" ", "_", $name) . "_" . $page->id; $newNameSave = $sanitizer->pageName($newName, "Sanitizer::translate"); $page->name = $newNameSave; $message = __("Benutzername wurde angepasst: ") . $newNameSave ; $this->message($message); } } But every time I try this, "Test Üser" becomes "test_ser_1552". The same goes for "Test üser". If I try "Test Güser", I get "test_g-ser_1552". So ü gets replaed by a dash -. When I create regular pages (e.g. basic-page template) the conversion of Ü and ü to ue for the page name is working just fine. Could there be a problem with using $sanitizer->pageName($newName, "Sanitizer::translate"); inside a module? Or is the username field treated differently from the page name field? Any solution would be much appreciated.
  6. if ($page->trackChange('name_of_you_field')) {...} got triggered for me on every page save, no matter if the value of my field had changed or not. Changing it to if ($page->isChanged('name_of_you_field')) {...} brought the desired result. See also $page->isChanged("field") in API cheat sheet
  7. When creating a new page with multilanguage page names, under the Settings tab there is a field for the page name for each language with an "Active" checkbox. By default the chachbox is checked How can I set them to be unchecked by default? I tried to find settings in LanguageSupport and LanguageSupportPageNames modules and in the settings for the languages.
  8. Hello, in a 2.6.22rc1 install I have a page field "workshops" that selects pages via selector "template=workshop,sort=-dat_start,dat_start>=today)". The field is in a template "anmeldungen". When I edit a page with template "anmeldungen". I can choose pages from the page field "workshops". But when I want to save that page, I get an error Page 2188 is not valid for workshop (Page 2188 does not match findPagesSelector: template=workshop,sort=-dat_start,dat_start>=today) But the workshop I am trying to save to the page field is definitely in the date range >=today. Otherwise it wouldn't be listed in the page field select dropdown. The same error is thrown when I change my selector to "template=workshop,sort=-dat_start,dat_start>=2015-11-04". Also saving pages through the API to that field doesn't work. Only if I omit the dat_start>= selector, I can save pages to the page field.
  9. Thanks for sharing. Do you now still get the warning about the page name already being in use?
  10. Having a similar scenario here and would also like to know how to avoid that message for the backend. Would you mind sharing your small module here? I think we'd need a hook before page render in that module which unsets that specific notification. EDIT: Can't seem to find much documentation for working with the notification system from the API side. Looking at Ryan's post here it seems that notifications are tied to the $user object?
  11. For file uploads, you may want to look at Soma's example gist.
  12. OK, I see. Yes, would be really nice to have such a module. I believe this post refers to how we can also delete image variations.
  13. @benbyf Do you mean to clean <img> tags from RTE fields where the associated images are gone for some reason? Take a look here. Or what does "cleaning images orphaned from the DB" mean? And making this into a module is somewhat difficult because in that module you would have to cater for all different constellations, like 3rd party modules that manipulate images, which is quite hard to anticipate for a potential module author.
  14. Sure this is another dependency. Using LESS/SASS you will always need some dependencies like preprocessors. But with package managers like bower etc. organizing dependencies is a breeze. And this can be used with any template approach, be it the delayed output strategy or not. What makes using LESS/SASS a big timesaver for me is that writing the CSS code becomes much faster. Also separating your CSS into chunks (partials) improves maintainability a lot.
  15. I was looking into cross browser save flexbox grid frameworks myself the last days and found http://leejordan.github.io/reflex/docs/. Haven't tried it yet, though. But might be worth taking a closer look.
  16. I'm using good old "compass watch" in the terminal from within my template folder to compile my SASS/SCSS. So I don't need any other tools than compass. A typical site/templates/config.rb (taken from my https://github.com/gebeer/site-pwbs profile) for compass looks like: require 'compass/import-once/activate' # Require any additional compass plugins here. add_import_path "bower_components/bootstrap-sass-official/assets/stylesheets" # Set this to the root of your project when deployed: http_path = "/" css_dir = "css" sass_dir = "sass" images_dir = "images" javascripts_dir = "js" # You can select your preferred output style here (can be overridden via the command line): # output_style = :expanded or :nested or :compact or :compressed
  17. gebeer

    Logo carousel

    In slick, if you set "autoplaySpeed" to something quite low (10 or so) and "speed" to something quite high (10000 or higher) you should get a nice result. See http://codepen.io/anon/pen/WQJPXr
  18. You could also accomplish this with pure CSS. Lets say your CKEditor content gets ouput in your template inside a <div class="maincontent">CKEditor content with <img> tags</div> If you are using SASS version of Bootstrap, in your scss you can do .maincontent img { @extend .img-responsive } If you are using plain CSS (taken from the img-responsive class) .maincontent img { display: block; max-width: 100%; height: auto; }
  19. Hello, I would like to utilize wire/modules/Inputfield/InputfieldIcon/ in a module. I found that icons.inc there does not include all FontAwesome 4.4 icon classes. Is the selection of icon classes in icons.inc opinionated for use in PW or is it just not up to date? Anyways, I put together some code to produce a icons.inc with all available FA icon classes from master branch, sorted alphabetically: <?php $url = "https://raw.githubusercontent.com/FortAwesome/Font-Awesome/master/src/icons.yml"; $faArray = yaml_parse_url($url); // pack all icon ids (classnames) in array and sort alphabetically $iconClasses = []; foreach ($faArray['icons'] as $key => $row) { $iconClasses[$key] = $row['id']; } array_multisort($iconClasses, SORT_ASC, $faArray['icons']); // write all fa classnames to a file $file = "icons.inc"; $prefix = "fa-"; $out = fopen($file, "w+"); foreach ($iconClasses as $c) { $class = $prefix . $c . PHP_EOL; // echo $class . "<br>"; fwrite($out, $class); } fclose($out);
  20. I am converting a Joomla/Seblod install and in that process developed a widget system quite similar to Marcrura's. In Joomla widgets are called modules and in that particular install those modules were used quite a lot. To render modules (widgets) in Joomla you do something like <?php if ($this->countModules('content_bottom')): ?> <div class="content_bottom"> <jdoc:include type="modules" name="content_bottom" style="inner" /> </div> <?php endif; ?> So I tried to find a way in PW to conditionally output widgets. In my widget template, I have widget positions and layouts as page fields, just like Marcrura shows. Plus a page field of type PageListSelectMultiple to determine on which pages to show the widget. And, like Berhard, I have a checkbox to determine whether to show the widget also on child pages. Instead of using includes for each widget position, I use switch case statements in my widget template // get layout $layout = $page->layout->name; // layouts switch ($layout) { case 'carousel': // code to render carousel markup echo $carousel; break; case 'teaser': // code to render teaser markup echo $teaser; break; // ... etc. I use the delegate template approach like in the default site template with an _init.php that gets prepended and a _main.php that gets appended and outputs variables that are being populated in the page templates. Here is the logic to render widgets in the main content area of my _main.php <main class="col-sm-<?php echo $contentwidth; ?> content equalHeight"> <?php if($above) { ?> <!-- widget position above --> <div class="above"> <?php echo $above; ?> </div> <?php } ?> <?php echo $content; ?> <?php if($below) { ?> <!-- widget position below --> <div class="row below"> <?php echo $below; ?> </div> <?php } ?> </main> $above and $below hold the markup for all widgets in that position on that page and are false if there are none. And this is the code I use to determine whether there are widgets in that particular position on that particular page. In my _init.php I first set all position variables ($above, $below etc.) to false. (module translates to widget here) // Set all module variables to false foreach ($pages->find('template=modulepositions_items') as $position) { ${$position->name} = false; } The widget position pages all have the template modulepositions_items. So I iterate through all positions and then use Variable variables to create the position variables ($above, $below etc.) and set them to false. This step is needed to avoid PHP "Undefined Variable" notices. In my _main.php I store the widget markup in the position variables before all the other template markup (again module translates to widget) // get modules $modules = $pages->find('template=module, sort=sort'); // render modules in their positions foreach ($modules as $module) { // if module is assigned to this page or it's parent, render it on it's position if (count($module->onpages) == 0) { // if no specific pages are assigned, render module on all pages ${$module->moduleposition->name} .= $module->render(); } elseif ($module->include_children == 1 ) { if ($module->onpages->has($page) || $module->onpages->has($page->parent('id!=1'))) ${$module->moduleposition->name} .= $module->render(); } elseif ($module->include_children == 0 && $module->onpages->has($page)) { ${$module->moduleposition->name} .= $module->render(); } } Lets brake this down: "onpages" is the page field in my widget template that determines on which pages to show the widget. ${$module->moduleposition->name} .= $module->render(); renders the markup $module->render() of the widget and adds it to the position variable ${$module->moduleposition->name} which again is a variable variable (just like that expression too much ) The if and elseif statements check whether the widget should be rendered on that particular page. They feel a bit clumsy and I think I will change my setup to using the selector field instead. To summarize: with this method you get a quite flexible widget system with the benefit of minimizing the code used to render them in _main.php and the possibility to have conditional markup depending on whether there are widgets for that position or not. Thank you guys for sharing your approaches which gives me some good ideas for improving on my own.
  21. Hi Roych and welcome to the forum! There is Damienov's function for rendering a bootstrap 3 dropdown menu. So no need to reinvent the wheel You need to include that function somewhere in your template. E.g. you could make a file functions.php and put that function inside and save it to site/templates/inc/functions.php. Note that this part does NOT belong in your functions.php, only the function itself: // bundle up the first level pages and prepend the root home page $homepage = $pages->get(1); $pa = $homepage->children; $pa = $pa->prepend($homepage); // Set the ball rolling... echo renderChildrenOf($pa); Then in your main template or even in your init.php file you include the function: /* * Include any other shared functions we want to utilize in all our templates * */ require_once("./inc/functions.php"); Now in your template were you want to render the function you put this part: // bundle up the first level pages and prepend the root home page $homepage = $pages->get(1); $pa = $homepage->children; $pa = $pa->prepend($homepage); // Set the ball rolling... echo renderChildrenOf($pa); This should render a nice BS dropdown navigation.
  22. I need to revisit this thread because the problem has given me a headache agein today. It seemed like $page->render($options) cannot be used with the delegate approach where you assign your content to a variable in your template file and _main.php gets included and renders that variable. Here my setup to test this behaviour: basic_page.php <?php $gallery = $page->children()->first(); content = $gallery->render(array("useMain" => false)); $gallery has template gallery.php <?php if (isset($options['useMain'])) $useMain = $options['useMain']; $content = "<h2 class='page-header'>{$page->title}</h2> {$page->bodycopy}"; With this setup "$gallery->render(array("useMain" => false));" returns an empty string. if I change gallery.php to <?php if (isset($options['useMain'])) $useMain = $options['useMain']; // NOTE THE echo instead of $content = echo "<h2 class='page-header'>gbr{$page->title}</h2> {$page->bodycopy}"; Then I get the string that I would expect from "$gallery->render(array("useMain" => false));" So the culprit seems to be the $page->render($options) method not returning my $content variable from the gallery.php template. The solution is dead simple, though. gallery.php: <?php if (isset($options['useMain'])) $useMain = $options['useMain']; $content = "<h2 class='page-header'>{$page->title}</h2> {$page->bodycopy}"; if (!$useMain) echo $content;
  23. @IntegralHack You can find the code to get you started towards the end of post #10 in this thread. Of course, you would need to define your classes (in the example the classes are in /models/Product.php) that have the actual code for getting, putting, posting and deleting values. If you need to see some more code, PM me. It would be much appreciated if you could share some of the tricks and what the new things in PW are that you are talking about
  24. Hello, I was getting a setOutputFormatting error for a CKEditor field that had Content Type set to "Markup/HTML with image management" while trying to save HTML to that field in the course of importing about 150 pages through the API. This happened although $p->of(false) was set. It took me quite a while to figure out that this error was thrown only when there were image tags in the HTML that should be saved to that field. Then I went and switched Content Type for that field to "Unknown". Now the import worked fine. After switching Content Type back to "Markup/HTML with image management" and running the import again, there were no errors anymore. I just thought I'd mention this here in case someone else is facing similar problems. This happened on a 2.6.15 dev install.
×
×
  • Create New...