Jump to content

Autofahrn

Members
  • Posts

    328
  • Joined

  • Last visited

  • Days Won

    10

Everything posted by Autofahrn

  1. Since the icons seem to be used globally and everywhere, its probably best to go through something global to distribute it. I'd probably go through $config: $config->icons = Collection::fromPath('path/to/svg/files'); So you're able to access it everywhere from $config->icons or wire('config')->icons inside a class.
  2. or has a flatrate, like on mobile devices. ...and don't forget cropping with respect to the focus point.
  3. Thanks, @dragan, somehow expected a shorter answer like: The switch takes the first case matching the evaluated value... ? ...and: don't use goto... [ducking away] ?
  4. Just wondering what the switch will do if the array has three elements so $last equals two... ?
  5. The code does not look wrong to me, what's the exact error you encounter? If you only see a 500 you may either get the exact cause from the error log (Setup>Logs>errors) or you may activate debug mode in config.php ($config->debug = true;). In any case you probably want to install the Tracy Debugger... Instead of the if cascade you may consider using a switch statement.
  6. Indeed, at the moment there is no version available for testing, but this will change pretty soon. Since the RepeaterFlex is pretty similar to the RepeaterMatrix regarding its use (yet totally different regarding configuration), I've requested @ryan for an approval first on how to proceed. As a result the RepeaterFlex will be made available from the ProFields board after some final cleanup and documentation. ...hopefully next few days.
  7. probably not, since any file placed into your webspace will be served directly, they do not need to follow any particular nomenclature - that's just files. Happens also to any .js and .css files buried somewhere in a module's folder, for example. Before implementing admin pages for this purpose, why not simply extending InputfieldImage? You may use ImageExtra as a starting point...
  8. Instead of figuring out which variations may be added from functionality inside PW, why don't you simply place your variations into a subdirectory of the asset path (/site/assets/files/1234/happyvariations)? To enumerate those variations you do not go through $image->getVariations() but use the contents of that subdirectory? Of course you do not get an array of images but only the filenames. That way you may even encode other information into the filename and retrieve those information using preg_match. Depending on your use case this may even be a time-saver since the image files do not need to be opened. Of course you do not see those "private" variants in the admin and need to manage them completely from your scripts.
  9. Sadly no, at least not in admin or to my knowledge. If you like to have it sorted, think about using a PageTable instead. Probably not as comfortable as the repeater for this purpose.
  10. Well, it needs to be <?php namespace ProcessWire; not <?php namespace Processwire; ?
  11. TextArea fields using the CKEditor require a comprehensive configuration. I order to not duplicate this configuration for any CKEditor used in compound fields like tables, they require to reference an existing field (the settingsField) from where this configuration is taken. What version of PW/ProFields are you running? Normally the description is right beneath the settings field:
  12. Unless you do not have a CKEditor field named "1" you'll have to specify the name of an existing textarea field (using CKEditor) at settingsField. If your reference field is named bodytext, it would be: settingsField=bodytext
  13. I think more input is required to provide help. ? Do you enter the date via API or in backend? How did you define date and time input formats for your date field? If the date is not shown in the label (for an item holding a proper date value), double check if names are identical (field and in label definition) Does the "old template" now produce an error or simply does not show the date (check the name in that case)?
  14. I probably miss something and won't go through a selector for that purpose: <?php if ( ($page->id == 1116) // Page is Vets Overview || // OR ($page->parent->id == 1116) // Parent Page is Vets Overview ) { echo "My conditional content"; } ?> Any reason to use the same template for the overview and its children?
  15. Hello @MichielW and welcome to the forum and PW. The global PW variables (like $pages) are not directly accessible out of a class, you'll have to go through the wire() method or wire() function. $page_content = $this->wire('pages')->get("/info")->textblock; or $page_content = wire('pages')->get("/info")->textblock; Depending on your use context it probably would be better to hand over the $page via parameter (or cache its value in your class instance), to reduce re-fetching the same content from database with each call.
  16. As @szabesz mentioned, why not simply add the .php to the page name and disable "Should page URLs end with a slash?" in the template? Just tried, works well. You may even have a /index.php...
  17. At least adding fields to the user template is pretty uncomplicated and straightforward. I did this a lot in my forum implementation, the user template looks like this:
  18. Good point, @dragan https://stackoverflow.com/questions/2185320/how-to-enable-php-short-tags
  19. Looks like you've placed the inline script into a JS file, right? In that case you'll need a different approach to get the event data into the JS world, the PHP injection from <?= getEvents(); ?> does only work when you embed the whole <script>...</script> block into your markup.
  20. @happywire don't forget that a Page is not an array or similar, but a PHP object with protected and private fields. From the "top" (like print_r($page)) you may see some internal attributes (like the array of hooks), but you can not directly access those fields. To retrieve, for example, the table of hooks, you'll need to use an allowed method, like print_r($page->getHooks()). Same for any field placed on your template. Their content is not retrieved everytime you see a $page but only after an access. If you do something like $page->someField, then you do not access a member from that object, the Page object intercepts the access operator and retrieves 'someField' from the database, caches its content in the page object and performs any kind of output formatting specified for that particular field. So, to obtain a list of fields available on a particular page, you'll do a $page->getFields(), which you may use to enumerate all fields and dump their contents: foreach($page->getFields() as $fldName) { echo "{$fldName}: {$page->$fldName}<br/>"; echo '<pre>'; print_r($page->$fldName); echo '</pre>'; } Edit: if you print_r($page) before and after that loop you'll see the embedded ['data'] array populated. And similar will do for $image->getVariations();
  21. or simply reload... ? Why should it? This only would add redundancy of the same information which may go out of sync for some reason. On the downside for this filename-only implementation is, that there only may be one variant with a particular dimension. So you can't have a 300x300 variant with low and another one with high quality, for example. And if you later decide to use different scaling parameters, you'll need to delete the old variant (file) first for the new conversion to happen (see Pageimage::size() for a more detailed description).
  22. @Matze, if you own or consider ProFields, you may check out FunctionalFields as well. While conceptionally intended for text translations, I do not see a reason why this should not work here. If you write something like this in your template file: $thePainter = __text(' ', 'painter', 'label=painter, required=true'); $thePeriod = __text(' ', 'period', 'label=period, required=true'); $theCanvas = __text(' ', 'canvas', 'label=canvas material, required=true'); $theTechnique = __text(' ', 'technique', 'label=painting technique, required=true'); You'll see that in your page editor: If you add more text replacement in your template file, these are added to all artist's pages immediately. Sidenote: I'll have to set a space for the original text, otherwise the fields do not show up, so they are actually not empty in this example. While this may be what you are looking for on first sight, I'd encourage you to think about using page references instead. Information like canvas material or painting technique are not endless and will repeat over various artists. Using plain text input, you'll have to repeat all this each time. And, if you are going multi-lingual, you'll have to enter every translation for every artist. With page references you'll have many benefits, like faster searches (who is painting with this particular technique in that period), generally less data in your database (less data to transfer to build an index, for example), one point to enter that information and may even add more info about it. You may even create new "attribute-pages" on the fly when entering the artist's page.
  23. @happywire just a little hint about image variations: Image variations (those files with DOT <width>x<height> DOT <ext> nomenclature) only live in filesystem not in the database. If you externally (outside of PW) remove or create additional variants in the proper location (your /site/assets/files/<ImageID>) folder, these changes are instantly reflected to any image enumeration (for example getVariations() method). There is no need to visit the admin or do any manual update after each change. If you do a $image->size() that method only looks into the assets path of that particular image to ensure the requested variation (namely file with specified width and height nomenclature) exists. If that's not the case, it will be created on the fly. There is no big magic happening behind the curtains. I guess its much simpler to accomplish what you intend to do: Just instruct your external script to create the variant next to the original file.
  24. or, as @dragan said, if you do not need the preview in admin, just use the file field.
×
×
  • Create New...