Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/18/2019 in all areas

  1. I have linked to @teppo's fork and added him as an author on the module.
    4 points
  2. Here's a little text formatter module that redirects all external links found in a textarea (e.g. for hit counting) to a given URL. TextformatterExternalRedirect GitHub repo As TextFormatters do, this module modifies the contents of the textarea (HTML) at rendering time. It prepends the given URL to the link address for external links (http and https), optionally makes sure that the link is opened in a new window and allows you to add css classes to such links. All options can be configured in the module's configuration settings. Usage: Download the zip archive and extract it to site/modules, the rename the top folder to TextformatterExternalRedirect Go to the backend and select "Modules" -> "Refresh", then click "Install" for "External Link Redirect" Click "Settings" and configure the module Go into the field configuration for the field(s) you want this formatter to apply to and add it from the dropdown Done, now any external links in the configured fields will have the configured settings applied Feel free to leave feedback and post and questions you have here.
    4 points
  3. One last update for the day: master branch of the module is now at 0.5.0. This includes both the rendering features mentioned above, and a slightly more polished theming feature, where each theme can declare custom markup, styles, scripts, strings, etc. More details in the README file.
    4 points
  4. Hi @gebeer Just stumbled across this (I know my reply is a little late,) but it is totally possible to prevent your rest API endpoints from starting sessions by using the $config->sessionAllow; variable. If you define it to be a function that returns bool true or false, then it will be evaluated and the return value determines if the Session class constructor is allowed to start a new session. There's an example of it in the default wire/config.php file at line 245. Reproduced here... $config->sessionAllow = function($session) { // if there is a session cookie, a session is likely already in use so keep it going if($session->hasCookie()) return true; // if URL is an admin URL, allow session if(strpos($_SERVER['REQUEST_URI'], $session->config->urls->admin) === 0) return true; // otherwise disallow session return false; }; You just need to rewrite the function so it returns false for your API endpoint path. Make that change and add it to your site/config.php file, and I think that anything hitting your API endpoint directly will not have a session created for the connection. Hope that helps!
    4 points
  5. Try http://kartograph.org/
    2 points
  6. How about this 3D Interactive Mall Map over at Codrops?
    2 points
  7. I'd use ?: instead of ??. At least if you can trust the truthy-ness of the field's value if set (which should be okay for keywords and description). And... though not necessarily better, I sometimes add a generic method to the Page class to abstract away logic from the template. // in site/ready.php: wire()->addHook("Page::getWithDefault", null, function(HookEvent $event) use($pages) { $page = $event->object; $property = $event->arguments(0); return $page->get($property) ?: $pages->get(1)->get($property); }); Then your template code boils down to <?= $page->getWithDefault("meta_description") ?>
    2 points
  8. Hi @Manuel, I am afraid not... What about using the "Null coalescing operator" (if you are using php 7) or otherwise the ternary operator: echo $page->meta_description ?? $pages()->get(1)->meta_description; Just written in the browser w/o testing, hope it can help.
    2 points
  9. I have updated the code to add an option for that. The module is now available at GitHub. Check "Open in new window" in the module configuration to add a target="_blank" attribute (or replace an existing target attribute's value with "_blank").
    2 points
  10. In cases like these, the Internet Archive (previously called WaybackMachine) is the go-to source. Here's the article mentioned: https://web.archive.org/web/20181201112507/https://processwire.com/docs/tutorials/but-what-if-i-dont-know-how-to-code/
    2 points
  11. Hi @bernhard cool to see that you needed this module for your case. About your question, I quote myself : That's not the first time this question is asked, I will make the Process module installed automatically on the next version (which should be ready for the end of august).
    2 points
  12. I know this thread is marked as solved - but I wanted to make a few comments. @OLSA FWIW, Tracy Debugger has a scream mode that forces it to ignore the @ supression. Just enable it in the settings page if needed. @demhan If you are using GD, then I think it counts towards your process' memory limit. Try upping the max memory limit for PHP and see if that helps. (Link if needed)
    1 point
  13. You can use WireArray's explode method to get the required property(s) from your repeater. "socials" => $m->socials->explode(['title', 'url']) Pass it a function instead of a property name or names to add fancier processing: "socials" => $m->socials->explode(function($item, $key) { return [ "name" => $item->title, "link" => $item->url ]; })
    1 point
  14. I think trasferring it to me would be best, whatever this means in practice ? I'd rather keep the current name if it's an option. No need to confuse folks by new forks.
    1 point
  15. Guys - I can transfer the entry in the modules directory to @teppo if you want. Or if you're planning on creating a new version with a different name, maybe it's a new module in the directory? Let me know if you want me to make any changes. BTW - I am not a fan of frontend editing tools in general, but this one I actually don't mind providing for the right site - sometimes even for frontend only users.
    1 point
  16. I tried it without the redundant fetch of the page, it still throws an error of Null reference. Besides your explanation, which sounds reasonable, the following line does return a valid Page object: $page = $this->pages->get($data->id); Even if the Page isnt saved, it might be, because it isnt an ::saveReady Hook anymore, instead i changed it to ::added Hook. I still need to check the RepeaterMatrix in my Page to not be Null.
    1 point
  17. I already submitted it, and it's pending approval, so it should become visible in the next few days. The latest version on GitHub also lets you add custom CSS classes to the links.
    1 point
  18. Happy to move maintain of this module for @teppoif he is interested? I haven't had use for AdminBar in years. No idea how to transfer this on module director, anyone?
    1 point
  19. ech. Not feeling stupid at all. I checked InputFields settings, yet not the FieldType settings. Thanks for taking the time to help me out of noob mode.
    1 point
  20. These two are inside a Select Option fields. Check the setting if the fields are installed or enabled: Modules --> Core --> Fieldtype
    1 point
  21. Hi Torsten thanks for the question, I also stumbled upon this problem and couldn't find a solution so far. There are simple solutions in ExpressionEngine and Craft (https://docs.expressionengine.com/latest/channels/entries.html#fixed_order, https://docs.craftcms.com/v3/dev/element-queries/entry-queries.html#fixedorder), maybe I missed something. Here's a workaround, temporary test code from a current project: $itemIdsA ia an array of ids, $finder3A is an array with results from a rockfinder query. if(count($itemIdsA)) { foreach($itemIdsA as $key => $value) { foreach($finder3A as $item) { if($value == $item['id']) { echo '<li>'; $datumVon = strtotime($item['datum_von']); echo 'Autor: ' . $item['autoren_title'] . ' / Datum: ' . date('d.m.Y H:i', $datumVon) . '<br />'; echo '<h3>' . $item['title'] . '</h3>'; echo '<p>' . $item['teaser'] . '</p>'; if(isset($pma[$item['id']])){ echo '<p>Test Anzahl Leserbriefe: ' . $pma[$item['id']][0] . '</p>'; } echo '</li>'; } } } }
    1 point
  22. Sadly, Google doesn't seem to offer a cached view of such articles... Maybe we should ping @ryan ? Were those tutorials too much out-of-date, or was there any other reason they didn't make it to the redesign pool of content?
    1 point
  23. Hi, It looks like you are right: https://processwire.com/docs/tutorials/but-what-if-i-dont-know-how-to-code/
    1 point
  24. This is probably a perfect case for a custom textformatter. Those are invoked when the content of a textarea is rendered. Here's an example module that prepends a custom URL to all external links. You need to enter /my-redirect-link/?link= in the module's configuration after installation and configure the field in question to use TextformatterExternalRedirect. <?php namespace ProcessWire; /** * ProcessWire External Link Redirector Textformatter * * Prefixes the URL in each external link with a local URL that redirects to the * original URL after doing whatever it is that it needs to do. * * The URL to prepend is configured in this module's settings * (Backend: Modules -> Configure -> TextformatterExternalRedirect) * * It assumes that the prepended URL ends with a GET parameter and an equal sign, * so it urlencode()s the original URL. * * Example: * Link is <a href='https://processwire.com'> * Prepend URL: /myredirector/?link= * Textformatter generates: <a href='/myredirector/?link=https%3A%2F%2Fprocessire.com'> * */ class TextformatterExternalRedirect extends Textformatter implements ConfigurableModule { public static function getModuleInfo() { return array( 'title' => 'External Link Redirect', 'version' => '0.0.4', 'summary' => "Parses links in textareas and prepends a local redirector URL", ); } public function __construct() { parent::__construct(); $this->set("prependUrl", ""); } public function format(&$str) { $str = trim($str); if(!strlen($str)) return; if(!$this->prependUrl) return; $that = $this; $str = preg_replace_callback( '/(<a[^>]+href=)(["\'])([^"\']*)(\\2)/i', function($match) use($that) { // If link is not external, we return the original link if(!$that->isExternalLink($match[3])) return $match[0]; return $match[1] . $match[2] . $that->prependUrl . urlencode($match[3]) . $match[2]; }, $str ); } public function isExternalLink($url) { foreach($this->config->httpHosts as $hostname) { // If the target host is one of our own hostnames, // this link is not external. if(preg_match("~^https?://{$hostname}~i", $url))) return false; } // Otherwise, all http(s) links are definitely external // and get redirected. if(preg_match('~^https?://~i', $url))) return true; // No match, then we have a relative url (internal) or some other // scheme (e.g. mailto) that we don't redirect. return false; } public static function getModuleConfigInputfields($data) { $inputfields = new InputfieldWrapper(); $f = wire('modules')->get("InputfieldText"); $f->attr('id+name', 'prependUrl'); $f->label = __("URL to prepend", __FILE__); $f->description = __("This URL is prepended. It is assumed that it ends with a GET parameter to which the URL-encoded original link will be passed.", __FILE__); if(isset($data["prependUrl"])) $f->attr('value', $data["prependUrl"]); $inputfields->append($f); return $inputfields; } }
    1 point
  25. Just for a test copied this to /site/init.php, removed bd() calls (don't have Tracy installed), and it worked like a charm. 404 page gave me "test". So... another module, another hook, Tracy (?), or something else interfering? You mentioned site/ready.php and init() of an autoload module, but in my test I used site/init.php. That probably shouldn't matter in this case – though not 100% sure ?
    1 point
  26. I've been in Minnesota all week for a family reunion and only a few minutes at the computer every day, so I don't have a core update or anything worthwhile to write about this week. But now I'm headed back home so will be back to a regular schedule next week. Hope that you have a great weekend!
    1 point
  27. Any chance you are using these inside a function or module? In that case you'd need: wire('config')->urls->root Do you have debug mode turned on? That should let you know that you have an undefined variable: $config
    1 point
  28. This is correct, $page->httpUrl is what you are looking for, and it will include the port as well. It will also account for https if the page in question is configured to use https from its template settings. The equivalent of $config->urls->root that you are looking for then would be: $pages->get('/')->httpUrl; Just note that it has to be accessed at it's URL in order for it to know it. So if you are working with the command line API, it's not going to know it...
    1 point
×
×
  • Create New...