Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. 1. Create all the fields you need relating to a single car. One field you don't need to create is "Title" because that is a global field that exists by default. 2. Create a template "car". To this template add the fields you created in step 1. This is the template that will output the fields for a single car. 3. Create a template "cars". This is the template that will output the list of cars. If it only outputs the list of cars it may not need any fields added to it apart from the default "Title". 4. Create a page "Cars" that uses the template "cars". 5. Create a child page of "Cars" for your first car that uses the template "car". Fill out the fields. Repeat this step for all your cars (see end of post for a time-saving tip). 6. Create template file "car.php" in /site/templates/. In this file output your fields as needed, getting each field as $page->my_field_name 7. Create template file "cars.php" in /site/templates/. In this file you will get a PageArray of all the cars and then loop over them to create links to the individual car pages. // get PageArray of all cars $cars = $pages->find("template=car"); // in this example you could also get $cars with: $cars = $page->children(); // Output list of links... if(count($cars)) { echo "<ul>"; foreach ($cars as $car) { // $car is the Page object for an individual car // You can get any field of the car with $car->my_field_name echo "<li><a href='{$car->url}'>{$car->title}</a></li>"; } echo "</ul>"; } Time-saving tip: you could import data for your car pages in bulk from a CSV using this module.
  2. You can filter the notices with a hook before Page::render in /site/ready.php The file compiler notices are useful information so probably sensible to filter these notices only for non-superusers. $this->addHookBefore('Page::render', function($event) { $user = $this->user; if(!$user->isSuperuser()) { $notices = $this->notices; $notices->not("class=FileCompiler"); $notices->not("text~=Compiled file"); } });
  3. Hi Nico, Welcome to the forums. Just wondering why you don't want to use the backend to edit your pages. My take is this: the whole point of the frontend edit features is that you stay on the page being edited. If you are navigating to a separate page for editing then that might as well be "Edit Page" in the backend - no need to reinvent the wheel. You can display a link to Edit Page in the frontend only to users who may edit the page: if($page->editable()) { echo "<a target='_blank' href='{$page->editURL}'>Edit this page</a>"; } Or if you wanted to keep the /url/to/page/edit/ scheme you could redirect to Edit Page: if($input->urlSegment(1) == 'edit') { if($page->editable()) { $session->redirect($page->editURL); } else { throw new Wire404Exception(); } }
  4. There have been a few issues raised here in the forums that seem to relate to SQL mode settings. There is nothing stated on the requirements page about SQL mode but it seems that certain mode settings can cause problems, and maybe even settings that are now enabled by default in MySQL 5.7. Might be a question for @ryan, or does anyone else know: What are the SQL mode requirements for ProcessWire?
  5. The settings for the CKEditor field are viewable in the page source of Edit Page: You could inspect the source to see where any other references to "mystyles" might be coming from.
  6. "mystyles" is working normally for me in the latest PW 3.0.28. Where do you see the error message - in your browser JS console? The error sounds like there is an attempt to load "mystyles" twice. Just guessing here - do you have anything in the "Custom Config Options" for the CKEditor field that refers to mystyles?
  7. I don't think this is quite right. If the image you are uploading is 200px high and the minimum height for the field is 260px then PW will refuse it, regardless of what is set for max width/height. So that part is okay. The problem happens when you set a max width/height and the image you upload is larger than both the max width/height and the min width/height. What happens here is that PW resizes the image to so it is contained by the max width/height while maintaining the image aspect ratio. And depending on the aspect ratio this can result in a resized image where one dimension (width or height) is smaller than the min width/height. So in the example you give... ...PW will actually scale a 1024x768 image down to 320x240, not 320x260. PW doesn't refuse the image because it was larger than the min width/height on upload, but it doesn't check if the resized image will be smaller than the min width/height limits. Arguably this should be checked, but if if what you want is an image cropped to exact dimensions you can just leave the max width/height empty (or some large maximum to avoid overly massive files - I often set max width to 1600px) and crop to your dimensions in your API calls: $image->size(320,260)
  8. Probably not the cause of your problem, but it is not valid HTML to wrap a link around a list item. The only element that can be a direct child of <ul> is <li>.
  9. Cool module! A couple of ideas/dreams for a future update: 1. It would be great to have thumbnails in the select dropdown for image fields. 2. Could there be an option for the last select in the chain to be a select multiple?
  10. If I understand right, you will be outputting all the repeaters on the parent page and each of these will include a link to the booking page. Because a repeater item is a page you can use the page ID to identify it. So on your parent page... foreach($page->my_repeater as $repeater_item) { $link = "/booking/?id={$repeater_item->id}"; // output the markup for your repeater item including the link } And on the booking page... $id = $sanitizer->int($input->get('id')); $repeater_item = $pages($id); if($repeater_item->id) { // output the markup for your repeater item } You could use a URL segment instead of a GET variable if you prefer.
  11. No pressure, but eagerly looking forward to using Batcher in PW3. In PW2 it was my go-to module for quick and easy bulk deletion of pages generated during site testing. Lister Pro can do that too but needs more clicks. Please keep the option of typing a selector too.
  12. Thanks for the suggestion. I haven't used Glyphs (it's not cross-platform and I'd need to upgrade my ancient Mac) but I was aware it can export webfonts. Because Glyphs is a font creator/editor first-and-foremost I think the workflow for webfont conversion might be a bit slow. I figure you would have to open and export each font individually. Or maybe some sort of batch script is possible. I heard back from Font Squirrel this morning and they have de-blacklisted the fonts I noted above. I'm pleased about that, and it sounds like I can contact them whenever I find a font that is wrongly blacklisted and they will correct that. So I think I'll persevere with Font Squirrel wherever possible and fall back to Transfonter if needed.
  13. I don't really understand what your page structure is and what you are trying to output. Maybe you could show... the structure of this branch of the page tree what templates are used at each level an example of what you want your output to be ...then it would be easier to help. But generally I think the problem is that you need to get $categ_team_year and $past inside your loop, using $categ. Also, you need to use count() in your if() statements when testing if a PageArray is empty. Maybe something like: $categ_team = $page->children("template=categ_team"); foreach($categ_team as $categ) { $categ_team_year = $categ->children("template=categ_team"); $past = $categ->find("template=member, actual=0"); $content .= "<h2><a href='{$categ->url}'>{$categ->title}</a></h2>"; if(count($categ_team_year)) { foreach($categ_team_year as $year) { // do something with $year } } if(count($past)) { foreach($past as $member) { // do something with $member } } }
  14. You could follow the example of the core Datetime fieldtype module and convert back and forth from SQL datetime to Unix timestamp on sleep/wakeup.
  15. Your templates folder has 777 permissions - some hosts don't like this and will throw errors. And the permissions look a bit funny in general. For my sites all folders have 755 and all files have 644 (apart from config.php which is set to 400 for security reasons).
  16. strtotime() and time() both return a Unix timestamp, which is not the same format as MySQL datetime. To convert a timestamp to datetime format... date('Y-m-d H:i:s', $timestamp)
  17. What you have shown there is not the Family tab for the template - it's the Settings tab for the page. The Family tab for Template has two fields that may be relevant to your problem: "Allowed template(s) for children" and "Allowed template(s) for parents". Check the Family tab... for the template of the page you are trying to move and the template of the parent page you are trying to move it under ...and make sure the allowed templates permit the move you are trying to do.
  18. Yes, I think so. You may have good reason to develop locally in a subfolder, but I generally find it's easier to set up a virtual host for each project and then develop in the root of that virtual host.
  19. Thanks, I don't really understand the difference between these two. Do you mean there are situations where this works: wireRenderFile('somefile.php', $my_vars, $my_options) But this doesn't: wire('files')->render('somefile.php', $my_vars, $my_options) Or it's just a bit quicker/easier to do the first rather than the second? Edit: Confusion resolved . I just noticed that the wireRenderFile() function is different in PW 2.x versus PW 3.x. So it's only in 3.x that it's an alias for another method, so I can understand now why it was a new feature back when Ryan announced it in PW 2.5.2.
  20. Thanks for the replies. I licensed FontPrep years ago when it was a closed-source app, and even bought an old Macbook especially to run it on (I'm a PC user normally). The downsides to FontPrep are bugs, no WOFF2 support, and the fact that subsetting has to be manually specified for each individual font. But is seems like it's just about the only show in town for desktop webfont conversion with a GUI (the only other alternative I can see is TransType which doesn't even do subsetting). To be honest I think the main reason I don't use it routinely is the hassle of booting up another computer for a single task. And that's just laziness so I'll give it another look now that I'm running into problems with Font Squirrel. Thanks, I've used both of these in the past. While neither has anything like the feature set of the Font Squirrel generator and Fontie has no WOFF2 support they do at least work for the wrongly-blacklisted fonts. Transfonter is my pick of the two because it generates WOFF2 and allows the conversion of multiple fonts simultaneously. It does surprise me that there aren't more offerings for quality webfont conversion. It's something I'd happily pay for. I'd love to know how much market share the Font Squirrel generator has. Seems like a lot of eggs in one basket - if they shut up shop for one reason or another it would be a minor catastrophe.
  21. The Font Squirrel webfont generator has been giving me grief recently. Changes seem to have been introduced that give me two problems: 1. A number of freely licensed fonts can no longer be converted to webfonts due to false positives on some kind of generalised blacklist. It seems that the vendor of the font is checked on upload and if that vendor also sells retail fonts then the uploaded font cannot be converted. Even some fonts downloaded from Font Squirrel itself can no longer be converted. Examples: https://www.fontsquirrel.com/fonts/source-sans-pro https://www.fontsquirrel.com/fonts/clear-sans 2. Fonts that I have made customisations to in FontLab are now declared "corrupt" despite working normally in desktop applications, being convertable by other (inferior) online converters and previously working fine in the Font Squirrel generator. Anyway, this has made me realise how dependent I am on a single online service and I'd like to find a good alternative if possible. Does anyone know of a Mac or PC desktop application that can generate webfonts with anything approaching the level of control possible in the Font Squirrel generator? Or a good online alternative? I need features like: WOFF2 generation custom subsetting OpenType features & flattening Thanks for any suggestions.
  22. I remembered a blog post where Ryan introduced a new function wireRenderFile() for rendering a file and returning its output. But when I searched the new v3 API docs I couldn't find wireRenderFile() - instead I discovered $files->render() and WireFileTools::render() that seem to do the same thing as wireRenderFile(). And looking at the code it seems that wireRenderFile() is basically an alias for $files->render() which in turn is a shortcut to TemplateFile::render() see edit below As a learner developer all of this got me wondering: 1. What is the benefit to making a new function like wireRenderFile() that seems to be just an alias for an existing method? I know there must be one because otherwise it wouldn't have been announced as something new in Ryan's post. 2. Is there a significant difference between WireFileTools::render() and $files->render()? The API docs say they are both shortcuts to using the TemplateFile class but unlike wireRenderFile() it looks like the code for WireFileTools::render() is not just an alias for another method but is actually independent. see edit below Edit for posterity: I think I have it sorted out in my head now... wireRenderFile() = $files->render() = WireFileTools::render(), and WireFileTools::render() makes use of TemplateFile::render() as part of the method.
  23. $categ->Children() ...should probably be... $categ->children() And... $content .= $page->render("member"); ...should probably be... $content .= $member->render(); You are also missing a semicolon at the end of this line... $content .= "<h2>{$categ->title}</h2>" I haven't used the render() method a great deal so I'm not sure of all the ins and outs, but it looks like you are using delayed output so you could run into issues where your _main.php gets auto-appended to your member template when you render it. And that wouldn't be what you want. Are you actually showing the pages using the member template as individual pages on the front-end? Or do you only use their content inside other pages? If the latter you might be better off not having a template file for the member template. So do something like this... foreach($categ->children as $member) { $content .= "<p>{$member->summary}</p> <p>{$member->project}</p> <p><a href='{$member->one_image->url}'><img src='{$member->one_image->url}' alt='{$member->one_image->description}' ></a></p>"; } If you output this same content structure in other templates and want to avoid repetition you could use a function or include to output the member content.
  24. Ryan has some good advice about field checks in this blog post.
×
×
  • Create New...