Jump to content

Robin S

Members
  • Posts

    5,039
  • Joined

  • Days Won

    340

Everything posted by Robin S

  1. 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)
  2. 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.
  3. 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.
  4. 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.
  5. 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.
  6. 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.
  7. 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.
  8. $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.
  9. Ryan has some good advice about field checks in this blog post.
  10. Soma's code should work for your situation (it works for me), but a couple of other possibilities... Use "include=all", but this would include unpublished repeater items which may be undesirable, foreach($page->my_repeater as $repeater_item) { $next_repeater = $repeater_item->next("include=all"); if($next_repeater->id) { // do something with $next_repeater } } Use getNext() foreach($page->my_repeater as $repeater_item) { $next_repeater = $page->my_repeater->getNext($repeater_item); if($next_repeater && $next_repeater->id) { // do something with $next_repeater } }
  11. Or maybe you mean the min/max image dimension limits? Fields > [image field] > Input...
  12. If your parent categories are siblings you can do this: $page->my_page_field->sort("parent.sort"); (You can do it anyway even if they're not siblings but the sort might not make much sense in that case.)
  13. As you found, PageTable does not work inside a repeater. See this post for a handy summary of what works and what doesn't with page-type fields. Can you work around this by getting rid of the repeater and adding a PageTable option that consists of just a title field? The UI would probably be nicer with RepeaterMatrix.
  14. @ryan, you say in the blog post: If a person is comfortable enough writing nested sub-selectors (or already has some code with nested sub-selectors) is there a reason to switch to the new a.b.c.d syntax besides it being more concise/readable? Would there be any performance difference?
  15. It's likely your problem is due to a XAMPP/sendmail configuration issue rather than the module. You can rule out the module by attempting to send a test email using PHP's mail() function. <?php $subject="Test mail"; $to="myaddress@somedomain.com"; $body="This is a test mail"; if (mail($to,$subject,$body)) { echo "Mail sent successfully."; } else { echo "Mail not sent."; } I found I had to jump through some hoops to get mail working in XAMPP. Here are some notes I made for getting mail to send via Gmail's SMTP server.
  16. A couple of few thoughts... 1. Compare a couple of output folders to work out which files are unique and which are identical. No point in linking multiple copies of the same file. I suspect that files like pano-player.js are the same for every export so you can hardcode the path to such files in your template. 2. You want a field in your template that stores a reference to a folder. For each page you select the parent folder that contains the unique files for that photo. You could use the module suggested by @Craig A Rodway which would be fine if you are the only person selecting folders. But if you wanted to lock it down a bit more so only the child folders of a particular folder may be selected you could make your own fieldtype module. Have a look at this module by @Martijn Geerts as a guide. The part you would change out would be the bit where the selectable options are defined... foreach($this->forms as $formName) { $inputfield->addOption($formName, $formName); } Instead of an array of FormBuilder forms you want an array of folder names, which you can get using PHP's glob() function with the GLOB_ONLYDIR flag. $directories = glob($somePath . '/*' , GLOB_ONLYDIR); 3. Instead of an iframe to index.html you can look at the contents of index.html and work out how you can generate the necessary code inside your template. It will probably involve getting the image file names from the 'images' folder and iterating over them. The glob() function will come in handy again here.
  17. Datetime fields are stored in the DB as timestamps - this is true regardless of whether you have a timepicker on the inputfield or not. So you can output the value of a datetime field in any format you like. Get the timestamp with getUnformatted() and then format it with date(). You could check the time to see if it's 12:00am and if so format the timestamp without a time component. But I don't think you can use code to distinguish between situations where no time was entered and 12:00am was deliberately entered.
  18. Ooh, ooh, me first! You should grab a template, give it a document, tag and description fields There's no document library module (that I'm aware of), probably because a module isn't needed for something like this. For your task the basic item you are dealing with is a document record. This is a collection of information: URI, description, tags. In ProcessWire the 'page' is the unit that is typically used to store a collection of information. And in ProcessWire, a page isn't necessarily a complete page that visitors view on the website front-end; a page can consist of only a title field, and you will probably use something like this for your tags/categories. The broadened definition of 'page' in PW is one of the things that can be confusing at first for new users. It took me a bit of time to adjust my idea of what a page can be. So as you predicted, you would create a template to use for document records and give it the fields you need. Then you add one page per document under a chosen parent in the page tree. It's up to you whether you make individual document records viewable as individual pages on the website front-end. You might decide you don't need that and only pull in information from the records to display as part of another page (search results or category listings). A great place to start is Ryan's Skyscrapers profile: http://demo.processwire.com/ http://modules.processwire.com/modules/skyscrapers-profile/ Replace the concept of 'skyscraper' with 'document' and you'll see how PW can be used as a document library. I did exactly that for the first website I built with PW: http://ref.dunestrust.org.nz/
  19. Besides using the Fieldtype module @LostKobrakai suggested (I haven't used it myself), you could create a simple Process module to list pages with the product template alongside the calculated VAT inclusive price. Check out the example module code shared by @renobird here. Edit: I just installed RuntimeMarkup and it works great for math calculations. So using this module would be the way to go if you want to see calculated values in a Lister.
  20. I'm no expert in this, but the way I see it is you have a base price and then one or more 'modifiers' that act on the base price. A modifier could be a tax rate, an export tariff, an addon handling fee for a large item, or something else. You don't work out the results of these modifiers for each base price ahead of time, you just apply them using PHP math operations as needed depending on what options the website visitor has selected. I think the performance impact of basic math operations like this would be negligible.
  21. Me too. I switch Tracy on only when I need it. Having a shortcut to toggle Tracy on/off would be great.
  22. Another solution... Instead of wrapping the link around the textarea on the index template, place the link as a sibling to the textarea and then use CSS absolute positioning to place it over the textarea. index-template <div class="my-text"> <a class="my-link" href=""></a> <?php echo $page->textarea; ?> </div> CSS .my-text { position:relative; } .my-link { position:absolute; width:100%; height:100%; top:0; left:0; z-index:2; }
  23. Rather than having two price fields... price price_including_vat ...have you considered having one price field and one VAT rate (%) field? price vat_rate And then you calculate the VAT inclusive price on-the-fly. Seems like it would be easier to maintain this way.
  24. Hi sudodo, Welcome to the ProcessWire forums. Sorry to hear you're having trouble. The admin login page at http://rightangle.space/processwire/ is loading normally for me. If you are seeing an error message when attempting to access this page could you post back with the contents of the message? Do you still get the error if you try a different browser? And if you access the page in your browser's private/incognito mode?
  25. Hi Barido, Welcome to the ProcessWire forums. I think there will be a number of solutions you can choose from. A few that occur to me are below. 1. Without using any modules and just working with the default Pages tree, you could use either the Published/Unpublished state or the Hidden/Unhidden state of the job page to switch a job from Active to Inactive (or vice versa). These states can be set directly from the Pages tree without needing to open the page for editing, as shown in the screenshot below. If inactive jobs need to be shown on the website front-end then the Hidden/Unhidden state would be the one to go with. In your templates you can test for the hidden state using the $page->isHidden() method. 2. You could use the Batch Child Editor module to toggle the Published/Unpublished or Hidden/Unhidden state. 3. You could purchase the Lister Pro module. This module has a number of cool features, one of which is the inline editing of page fields directly in the page list. So if you wanted to use a checkbox field in the job page to store the active/inactive state you could toggle this field via Lister Pro.
×
×
  • Create New...