Jump to content

abdus

Members
  • Posts

    743
  • Joined

  • Last visited

  • Days Won

    42

Everything posted by abdus

  1. Here it is in a hook. Use it with $pages->get(1234)->setPublished($timestamp), where you can get timestamp using strtotime or edit hook to build a date formatted as Y-m-d h:i:s wire()->addHookMethod('Page::setPublished', function (HookEvent $e) { $page = $e->object; $timestamp = $e->arguments(0); if (!$page->id) return false; if (!$timestamp) return false; $date = date('Y-m-d h:i:s', $timestamp); $query = $e->database->prepare("UPDATE pages SET published=:pub_date WHERE id=:page_id"); $e->return = $query->execute([ ':pub_date' => $date, ':page_id' => $page->id ]); });
  2. Hey @ryan loving these fieldset updates, keep them coming. I was holding myself not to start building a website until I can get my hands on these. Now having tried FieldtypeFieldsetPage, I've found it really useful for page meta (tags, categories etc) and SEO (seo title, desc) related fields. I also have a bug to report. ProcessPageEditLink crashes when it tries to get the list of files (when adding a link with CKEditor). It can handle basic repeater and repeater matrix pages properly but not FieldtypeFieldsetPage, and I get this error: Problem comes from this part. $repeaterPage is the id of repeater item, not a fully loaded Page instance. protected function getFilesPage(Page $page, $prefix = '') { $files = array(); foreach($page->template->fieldgroup as $field) { $type = $field->type; // ... } else if(wireInstanceOf($type, 'FieldtypeRepeater')) { $value = $page->get($field->name); if($value) foreach($page->get($field->name) as $repeaterPage){ // repeater page is page id, not a Page instance!! $files = array_merge($this->getFilesPage($repeaterPage, $field->getLabel() . ': '), $files); } } } return $files; } For now, I'm skipping FieldtypeFieldsetPage using: if(wireInstanceOf($type, 'FieldtypeFieldsetPage')) continue;
  3. How about: Header set X-Frame-Options SAMEORIGIN? https://stackoverflow.com/a/18057766
  4. @szabesz I was looking for that post, but couldn't find it. I'm using the same hook but without a placeholder image. I hope using placeholder will convince my editors. Thanks for linking it ?
  5. These tutorials by @Michael van Laar should help you get started https://digitalardor.com/articles/cms-content-blocks/ https://digitalardor.com/articles/basic-setup-for-content-blocks-in-processwire/ Also https://processwire.com/api/fieldtypes/repeaters/
  6. You can do something like this to show a featured image only when child page has one. <?php $posts = $pages->find("template=blog-post, limit=12, sort=-blog_date"); ?> <?php foreach ($posts as $child): ?> <div class="col-3"> <?php if($featured = $child->images->first): ?> <img src="<?= $featured->size(400,200)->url ?>" alt="<?= $featured->description() ?>"> <?php endif; ?> <a href="<?= $child->url ?>"><?= $child->title ?></a> </div> <?php endforeach; ?> I'm not particularly a fan of assignments inside if statement, but it's concise and seems to fit here.
  7. abdus

    How Much To Make

    Which website? Edit: http://howmuchtomake.com/
  8. Are you building a multi-language website? When saving multi-language fields, PW appends language id to fields. 1012 is the language id for a language installed in PW. You can use $pages->get(1012)->title to see which. To set description for an image you should first set field to accept descriptions. Go to Fields > image_field > Input > Number of rows for description field. Then enter a description for your image When you save the page, you should be able to get image description using $image->description(). From the core documentation: // $image = $page->image_field->first /** * Get or set the file’s description (with multi-language support). * * When not in a multi-language environment, you can still use this method but we recommend using the simpler method of just * getting/seting the `Pagefile::$description` property directly instead. * * ~~~~~ * // Get a Pagefile to work with * $pagefile = $page->files->first(); * * // Setting description * $pagefile->description('en', 'Setting English description'); * $pagefile->description('de', 'Setting German description'); * * // Getting description for current language (whatever it happens to be) * echo $pagefile->description(); * * // Getting description for language "de" * echo $pagefile->description('de'); * ~~~~~ * * #pw-group-common * #pw-group-manipulation * * @param null|bool|Language|array * - To GET in current user language: Omit arguments or specify null. * - To GET in another language: Specify a Language name, id or object. * - To GET in all languages as a JSON string: Specify boolean true (if LanguageSupport not installed, regular string returned). * - To GET in all languages as an array indexed by language name: Specify boolean true for both arguments. * - To SET for a language: Specify a language name, id or object, plus the $value as the 2nd argument. * - To SET in all languages as a JSON string: Specify boolean true, plus the JSON string $value as the 2nd argument (internal use only). * - To SET in all languages as an array: Specify the array here, indexed by language ID or name, and omit 2nd argument. * @param null|string $value Specify only when you are setting (single language) rather than getting a value. * @return string * */ public function description($language = null, $value = null) { /* ... */ }
  9. Here's WireArray::first method public function first() { return reset($this->data); } Documentation for reset() function says Returns: the value of the first array element, or false if the array is empty. Error: Call to a member function size() on a non-object i.e. boolean false happens because $child->images is empty for a certain child. A simple JS should help you pinpoint the faulty page. foreach ($pages->find("template=blog-post, limit=12, sort=-blog_date") as $child) { if (!is_object($child->images->first)) { $content .= "<script>alert('something wrong with $child->name')</script>"; } $content .= // ... }
  10. Profields: PageTable module works similar to this (it's available for free on dev branch) You can edit children as you're adding them inside the parent. Here's some discussion about what it is and how it works EDIT: I missed the referencing part, you can disregard this comment.
  11. abdus

    Song Titles

    I dont think search engines care about keywords anymore. This leaves you title, description and page content to attract visitors. https://webmasters.googleblog.com/2009/09/google-does-not-use-keywords-meta-tag.html https://blog.kissmetrics.com/meta-description-magic/ When you fill those fields, they show up on the page correctly, but how they work against other links is another question. <!DOCTYPE html> <html dir="ltr" lang="en-gb"> <head> <meta name="keywords" content="Always On My Mind, Apache, Beethoven's 5th, By The Time I Get To Phoenix, Dream Theatre - Best of Times, Fandango, Nights In White Satin, Phantom Of The Opera, Rave On, Skyfall, That'll Be The Day, The Loner, Walk Don't Run, You Raise Me Up" /> <meta name="author" content="Administrator" /> <meta name="description" content="Volume 1 of Backing Tracks and Musical Notation plus Guitar Tabs for popular songs and instrumentals" /> <title>Trax-n-tabs - Wolf Trax - Vol 01</title> <!-- ... -->
  12. I'm still betting on cache. Modules.info cache holds information about which modules are installed. Mine looks like this: // Modules.info cache { "148": { "name": "AdminThemeDefault", "title": "Default", "version": 14, "autoload": "template=admin", "created": 1502621954, "configurable": 19, "namespace": "ProcessWire\\" }, "97": { "name": "FieldtypeCheckbox", "title": "Checkbox", "version": 101, "singular": 1, "created": 1502621954, "namespace": "ProcessWire\\", "permanent": true }, // ... } Try assigning an empty array to $config->preloadCacheNames in config.php to disable reading from module cache, and even manually removing Modules.info from caches table in DB. /** * Cache names to preload * * Consists of the cache name/token for any caches that we want to be preloaded at boot time. * This is an optimization that can reduce some database overhead. * * @var array * */ $config->preloadCacheNames = array( 'Modules.info', //'ModulesVerbose.info', 'ModulesVersions.info', 'Modules.wire/modules/', 'Modules.site/modules/', );
  13. Clearing module cache usually helps Here's the relevant part from PW core. // ProcessModule.module protected function renderEdit($moduleName, $moduleInfo) { // ... $moduleId = $this->modules->getModuleID($moduleName); // ... if(!$moduleId) { $this->error("Unknown module"); return $this->session->redirect('./'); } // ... } And getModuleID() method: // Modules.php public function getModuleID($class) { $id = 0; if(is_object($class)) { if($class instanceof Module) { $class = $this->getModuleClass($class); } else { // Class is not a module return $id; } } if(isset($this->moduleIDs[$class])) { $id = (int) $this->moduleIDs[$class]; } else foreach($this->moduleInfoCache as $key => $info) { if($info['name'] == $class) { $id = (int) $key; break; } } return $id; } If PW cannot get the module from the cache, it returns 0, which sets of the error you're receiving.
  14. Check out this blog post on pagination implementation https://processwire.com/api/modules/markup-pager-nav/
  15. abdus

    Song Titles

    I am sorry to hear that. Don't let it discourage you from doing what you love. As for the website, it is using Joomla with a custom module (MyMuse). If it were vanilla Joomla, it would probably be easier, as most modern CMSs allow you to easily change templates as you see fit, and it's all well documented. But modifying a custom module, unless it's very popular might be daunting to someone with no expertise. I assumed you were thinking of transferring your system to PW, so I recommended some points to start off your research. Although it's not a quick solution, and it may sound like I'm preaching, but in the long run it might prove less costly to switch to a system that allows you and any developers you might hire to easily change the wesite to suit your needs.
  16. abdus

    Song Titles

    It looks like a good fit for @kongondo's Product Variations and @apeisa's Padloper (for e-Commerce) modules. Keep in mind both modules are commercial packages. I must admit I haven't used neither, but Product Variations allows you to create one product, and add many variations as you want. This could be useful for reducing the overhead for managing all products/songs and their variations. Padloper is the module for e-commerce, many people swear by it. Both modules are quite easy to integrate, as outlined by @kongondo. You dont have to use neither, and you can build your system from the ground up, but these are battle tested and works. As for the website, from what I gather, volumes are like albums that can house multiple tracks. This can be done as a parent-child relationship, or a categorization system. Not difficult at all. For SEO, having a fast website helps. PW helps you achieve that quite easily. Using custom fields you can add any information to any product and show them anywhere you want, there's no limit to it. I've found that having original and interesting content that you marketed to your target audience, and building a good volume of backlinks from reputable sources and through social media helps a lot in ranking. There's no one-size-fits-all solution, every website's needs are different and it needs constant effort to stay in the game against your competitors. https://www.padloper.pw/ https://processwire.com/blog/posts/padloper-brings-ecommerce-to-processwire/
  17. abdus

    Song Titles

    Can we visit the old/current website to see how it works?
  18. Each repeater item is a page itself, and repeater field is the parent page that holds these. (You can even see it under Admin>Repeaters). You need to iterate over $page->studioImages to get each set, than iterate over them to get individual images. Here's how: <?php foreach ($page->studioImages as $imgSet): // each repeater item ?> <div class="swiper-slide"> <div class="image-gallery"> <?php foreach ($imgSet->studio as $img): // each image in a repeater item ?> <a href="<?= $img->url ?>"> <div style="background-image: url(<?= $img->url ?>)"></div> </a> <?php endforeach; ?> </div> </div> <?php endforeach; ?>
  19. I'm not getting the error either. Are you using LastPass? Try disabling all extensions, and maybe starting with a fresh installation.
  20. Hey @adrian, thanks for the update. At the moment Tracy doesnt check whether ready.php and finished.php exists or not, and gives this error.
  21. @rick What has been logged to /site/assets/logs/errors.txt (also exceptions.txt)? It can help you pinpoint the origin of the error. EDIT: Hmm. I think after authorization with FB, it redirects back to your public endpoint with a token code, but it seems like something about that page or FB module causes error to be thrown
  22. @PWaddict change $templates as necessary $this->addHookAfter("Pages::saved", function($event) { $templates = ['product', 'post' ]; $page = $event->arguments[0]; if (! in_array($page->template->name, $templates)) return; $this->pages->sort($page, 0); });
  23. All three slides have the same image, unless that's the intended behaviour, or all images are the same, which I doubt, make sure you're using the current iteration element ($img) inside your loop. <div class="flexslider"> <ul class="slides"> <?php foreach ($page->slideImages as $img): ?> <li> <img src="<?= $img->width(1200)->url ?>" /> </li> <?php endforeach; ?> </ul> </div> Another thing is that you're loading 2 different jQuery scripts on the page. The one packaged with Foundation (under bower_components) is sufficient. <script src="bower_components/jquery/dist/jquery.js"></script> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.min.js">\x3C/script>')</script> In fact, why not use the slider that comes with Foundation instead? You're already loading foundation js files. http://foundation.zurb.com/sites/docs/orbit.html
  24. It needs to be set on every template file. Although there's template compiler that does it for you, I am not satisfied with how it performs. Here's the relevant blog post: https://processwire.com/blog/posts/processwire-3.0.14-updates-file-compiler-fields-and-more/#file-compiler-updates
  25. Assuming you're on >PW v3.0 It's most likely a namespace issue. Before if statement open a new PHP tag (<?php ?>) and specify namespace like so <?php namespace ProcessWire; ?> <?php if ( /* ... */) { ?>
×
×
  • Create New...