Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/20/2021 in all areas

  1. Are you using pagefileSecure? If you do, or otherwise use ProcessWire to send the file, you can change the config to force mp3s to always download using this incantation: $config->fileContentTypes = array_merge($config->fileContentTypes, ['mp3' => '+audio/mpeg']); The + sign in front of the mime type will tell PW to use the header “Content-Disposition: attachment” when sending the file type in question. Cf. https://github.com/processwire/processwire/blob/master/wire/config.php#L632
    4 points
  2. wireSendFile, forceDownload https://processwire.com/api/ref/functions/wire-send-file/
    2 points
  3. This isn't caused by ProcessWire; it's just the default behaviour of browsers. The same as if you followed a link to a JPG file the content would be shown in the browser rather than downloaded. The simplest way to have any link trigger a download is to add the "download" attribute to the <a> tag: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#attr-download If you were constructing the link markup in PHP by looping over the files in a Files field it would be easy to add that download attribute to the link. But it sounds like you are creating the links in CKEditor and it's a bit more difficult there because both ACF and HTML Purifier will strip out the download attribute by default. Rather than messing around trying to configure ACF and HTML Purifier to allow the download attribute I would simply add the attribute on the front-end with a bit of JavaScript. Here's how you could automatically add the download attribute to any MP3 link using jQuery: $(document).ready(function() { // Add "download" attribute to MP3 links $('a[href$=".mp3"]').attr('download', ''); });
    2 points
  4. Even if that's unlikely but if you are using RockMigrations that's as simple as setting a config variable: $config->filesOnDemand = "https://www.example.com"; https://github.com/BernhardBaumrock/RockMigrations/blob/02bc1b348b3e854d9a46b4cd79929f40233a2732/RockMigrations.module.php#L413-L453
    1 point
  5. dont think so ? Usually I do that via hooking ProcessPageEdit::buildForm and the wrapFields method of RM <?php $this->addHookAfter("ProcessPageEdit::buildForm", function(HookEvent $event) { $page = $event->process->getPage(); if($page->template != "yourtemplate") return; $form = $event->arguments(0); $rm = $event->modules->get("RockMigrations"); $rm->wrapFields($form, ['field1', 'field2'], [ 'label' => 'your fieldset label', 'icon' => 'bolt', ]); });
    1 point
  6. Maybe that's what you are looking for: https://processwire.com/blog/posts/pw-3.0.137/#on-demand-mirroring-of-remote-web-server-files-to-your-dev-environment
    1 point
  7. There is a hook Pages::cloned $this->addHookAfter('Pages::cloned', $this, 'pageCloned') and you can interact with the cloned page: /** * @param HookEvent $event * Method to change the status of a cloned page */ public function pageCloned(HookEvent $event) { // $return = $event->return; $page = $event->arguments(0); $clone = $event->arguments(1); $clone->of(false); $clone->modified = date("Y-m-d H:i:s"); $clone->created_users_id = $this->user->id; $clone->save(array('quiet' => true)); }
    1 point
  8. https://processwire.com/docs/front-end/markup-pager-nav/
    1 point
  9. Currently you could get this from the versionControlRevisions() method of the page. The value of said property is an array of all existing revisions, or null if none were found, so passing it to count() will tell you how many of those there were: echo count($page->versionControlRevisions());
    1 point
  10. Hi there, I´m using the basic navigation output from Ryan´s example site. I got Pages assigned to the Basic-Page Template which I don´t want to be shown in the Navigation. So here is my solution: Create a new field called: navhide Type: Checkbox Label: Do you want to hide this page from Topnavigation? Edit the Basic-Page Template and add the created field. Open your head.inc and add the following to where your Topnavigation shoud be outputted: <ul class="nav"> <?php $homepage = $pages->get("/"); $children = $homepage->children("navhide=0"); $children->prepend($homepage); foreach($children as $child) { $class = $child === $page->rootParent ? " class='active'" : ''; echo "<li$class><a href='{$child->url}'>{$child->title}</a></li>"; } ?> </ul> Please remember that the given html classes are from one of my projects, so feel free to add your own. You now find a new field in Pages assigned to basic-page template called navhide. If checked your Pages will be hidden in navigation. Hope this will work for someone
    1 point
  11. Not at all, appreciate your help. I think I've found what I'm looking for: <?php function treeMenu(Page $page = null, Page $rootPage = null) { if(is_null($page)) $page = wire('page'); if(is_null($rootPage)) $rootPage = wire('pages')->get('/'); $out = "\n<ul>"; $parents = $page->parents; foreach($rootPage->children as $child) { $class = "level-" . count($child->parents); $s = ''; if($child->numChildren && $parents->has($child)) { $class .= " on_parent"; $s = str_replace("\n", "\n\t\t", treeMenu($page, $child)); } else if($child === $page) { $class .= " on_page"; if($page->numChildren) $s = str_replace("\n", "\n\t\t", treeMenu($page, $page)); } $class = " class='$class'"; $out .= "\n\t<li>\n\t\t<a$class href='{$child->url}'>{$child->title}</a>$s\n\t</li>"; } $out .= "\n</ul>"; return $out; } echo treeMenu($page, $page->rootParent);
    1 point
×
×
  • Create New...