Jump to content

Robin S

Members
  • Posts

    5,039
  • Joined

  • Days Won

    340

Everything posted by Robin S

  1. There is a multi-language support subforum: you might do better to ask your questions there. I've never built a multi-language website myself as there is no demand for it in my part of the world (sadly Maori/English dual-language websites are rare in NZ).
  2. Although you can insert a static menu into your template, usually a CMS-powered website would use a menu that is generated dynamically according to the pages in the website. The text in the menu would be sourced from the titles of the pages. To create translations of page titles you can install the language support modules. I suggest you read the language support documentation, and the section about multi-language fields in particular.
  3. This isn't actually an installable profile though - you can explore the template files but without the database from the demo site it's not as useful as it could be. @ryan, could you please make an exported profile of the demo available?
  4. Based on the fact that you do not have URLs in the link hrefs I guess this menu is for navigating to blocks of content within a single page. Rather than hardcode this menu into the template and translate it using __() you could consider using a Repeater / Repeater Matrix for your content blocks and add a title field to your repeater items. Then you can create translations for the titles in Page Edit and generate your menu dynamically. Seems like it would be easier to maintain that way.
  5. If you want pages where a field is not empty you don't need to deal with the fieldsets/templates at all. Just: $count = $pages->count("title!='', has_parent!=2");
  6. Using a primary category in a parent-child relationship has some benefits: Visitors can see the relationship demonstrated in the URL and breadcrumb navigation The site structure is intuitive as visitors "drill down" through the page hierarchy to more specific pages There is some SEO benefit Finding a page in the admin page tree may be easier for site editors But this type of page structure is only possible (or only sensible) when a child page will belong exclusively to a single category of that type. So in the case of the skyscrapers demo it works for the city relationship as a building can only ever be in one city. But it wouldn't work for the architect relationship as it is conceivable that a building could be designed by more than one architect. And you wouldn't want to have duplicated building content under two ore more different architect parents. In the case of a turtle, you could for example use the taxonomical hierarchy in parent-child relationships: Trachemys scripta can only ever belong to a single genus, and so on up the hierarchy. But you wouldn't want to use "Native to" in a parent-child relationship as this would be both Mexico and the United States. @webhoes, matching to a page object / page ID like this is very reliable, but in most cases your Page field (habitat) will be limited to a single template and/or parent and the the titles of allowed pages will be unique. So you can cut out a step and do: $swampAnimals = $pages->find("template=animal, habitat=Swamp");
  7. Try: $template_has_title = $fields->get('title')->getFieldgroups()->implode('|', 'name'); $page_has_title = $pages->find("template=$template_has_title, has_parent!=2"); If you just want the count of the pages rather than the pages themselves you can do: $count = $pages->count("template=$template_has_title, has_parent!=2");
  8. A way you could do this without any code: 1. Create one image field for the first image and one image field for the second/subsequent image(s). 2. Set "Min width for uploaded images" to 200 for the first image field. Incidentally, your original post says that the first image should be under 200 pixels wide, but that doesn't make sense so I assume you mean over 200 pixels wide. 3. Make both image fields "required".
  9. When deciding whether or not to use a parent-child structure to create a relationship, the questions I ask are: 1. Is this relationship a primary (very important) relationship? 2. Do I want the relationship to be revealed in the page URL? (Note that other types of relationship may still be represented in a URL via the URL Segments feature) 3. Is the relationship exclusive? (i.e. may the child only belong to a single category/parent - you want to avoid a situation where the same page would appear under more than one parent). If the answer to any of these is "no" then I use a Page field for the relationship rather than a parent-child structure.
  10. If you just want a notification that a page is currently being edited by another user (like the default behaviour of Page Edit Soft Lock) then the optional core System Notifications module also has that feature. But if you want a "hard lock" option then I think Page Edit Soft Lock is the only option currently.
  11. Instead of... foreach($post->children("sort=-publish_date") as $child) { ...try... foreach($post->children()->sort("-publish_date") as $child) { I assume "publish_date" is a custom field you have added to your template - otherwise perhaps you are looking for "created". More likely "published". What's the deal with all the opening/closing PHP tags?
  12. There was a typo in the hook code I posted: should have been "parents" and not "parent". This should work... $nav = $modules->get('MarkupSimpleNavigation'); $nav->addHookAfter('getItemString', function(HookEvent $event) { $item = $event->arguments('page'); // if the item has more than one parent then it is a subpage if($item->parents->count() > 1) { $event->return = "<a href='{$item->parent->url}#{$item->name}'>$item->title</a>"; } }); // define your options array if needed and render your menu If not please post your MarkupSimpleNavigation code.
  13. Sounds like a good solution, but renderPager() will show a different number of pages on the first page than the others (because it is dividing 100 by 8 instead of 10). So you may need to use a custom pager to get around this.
  14. The hook example I gave will work, but you need to make sure the 'if' condition matches the child pages you are rendering inside their parent page. if($item->parent->count() > 1) {... If this condition isn't matching your child pages (I can't tell on your site - looks like it isn't installed in the hosting root) then change it to something that does. Like, maybe they have a particular template: if($item->template->name === 'my_template') {... Also, it looks like your container divs are using the page title for the ID when they should use the page name: <div id="Lieferservice" class="titelblock anchor"> ...should be... <div id="lieferservice" class="titelblock anchor"> Maybe it will help if you post your MarkupSimpleNavigation code.
  15. Not if PageArray 2 contains some of the same pages as PageArray 1. If you want to maintain the sort order make sure the PageArray you are importing has only unique pages not in the other PageArray. For example: $pa2->removeItems($pa1); $pa1->import($pa2); Regarding the %= operator, note that if there are multiple words in the search string then the entire string must appear in that exact order in the field(s) being searched. See this solution for allowing the words in any order/location:
  16. FYI, on Windows this issue seems to be specific to Chrome (or perhaps Webkit). Firefox and IE can delete heading text without affecting subsequent elements.
  17. You could write a simple textformatter module to replace instances of "my-simple-class" with "my-long list-of class-names".
  18. That is insane. Maybe time to move to a new host.
  19. Good to know - I had read on Stack Overflow that it was an efficient way to return the string of characters occurring before a substring but never tested it. Lets try that again... At the top of template files where child pages need the custom ".html" URLs: if(empty($options['pageStack']) && $input->urlSegment1) { $name = $sanitizer->pageName(rtrim($input->urlSegment1, '.html')); $p = $pages->findOne("parent=$page, name=$name"); if($p->id) { echo $p->render(); $this->halt(); } else { throw new Wire404Exception(); } } In /site/ready.php: $this->addHookAfter('Page::path', function($event) { $page = $event->object; $tpls = ['basic_page', 'some_template']; // define template names if(in_array($page->template, $tpls)) { $return = rtrim($event->return, '/'); // remove trailing slash if present $event->return = $return . '.html'; } }); Not that I think any of this is a good idea. Better to tell the SEO team that there is no reason to prefer /my-page.html over /my-page/.
  20. For the URL /products/product-one.html, as kongondo says ".html" will not be recognised a valid URL segment in the template for "product-one". But "product-one.html" would be a valid URL segment in the template for "product". So you would need to enable URL segments for every template and at the start of every template file you could have something like this: if($input->urlSegment1) { $name = strtok($input->urlSegment1, '.html'); $p = $page->children->get("name=$name"); if($p->id) { echo $p->render(); $this->halt(); } else { throw new Wire404Exception(); } }
  21. Assuming you are rendering your child pages in container elements with an ID matching the page name: $nav = $modules->get('MarkupSimpleNavigation'); $nav->addHookAfter('getItemString', function(HookEvent $event) { $item = $event->arguments('page'); // if the item has more than one parent then it is a subpage if($item->parents->count() > 1) { $event->return = "<a href='{$item->parent->url}#{$item->name}'>$item->title</a>"; } }); // define your options array if needed and render your menu You may want to block direct access to the subpages, in which case see this thread:
  22. A couple more options... At the top of the file for the template of pages you are including inside another page: if(empty($options['pageStack'])) throw new Wire404Exception(); if($page->url == $_SERVER['REQUEST_URI']) throw new Wire404Exception(); A related thread:
  23. Must be something wrong with your modified version. It works as expected for me:
  24. As a general rule, you can copy any PW module from /wire/modules/ to /site/modules/ if you want to customise it. When you do a Modules > Refresh you will see a notice... Session: Module "SomeModule" has multiple files (bold file is the one in use). Click here to change which file is used ...and you can enter the module settings to switch between the version in /wire/ and the version in /site/.
  25. You can certainly create your own plugin and toolbar button for CKEditor. PW doesn't get in the way of that, but it's something that you would learn about in the CKEditor docs rather than the PW docs. You can place your plugin in /site/modules/InputfieldCKEditor/plugins/ and then select it for CKEditor fields in the field settings on the Input tab. Or if you want to include your CKEditor plugin in a PW module you could have a look at how HannaCodeHelper does it. You will need to include the name of the toolbar button in the CKEditor Toolbar section of the field settings. Copy /wire/modules/Inputfield/InputfieldCKEditor/plugins/pwlink/ to /site/modules/InputfieldCKEditor/plugins/pwlink/ and make your changes there.
×
×
  • Create New...