Jump to content

Robin S

Members
  • Posts

    4,928
  • Joined

  • Days Won

    321

Everything posted by Robin S

  1. My knowledge of regular expressions is pretty weak - one of the things I need to improve on. If anyone can offer any help for the following scenario it would be much appreciated. I need to import a heap of content that contains Smarty tags for encoded email addresses. When I import the content I want to convert these tags to regular mailto links. An example tag: {mailto address="someone@domain.com" encode="javascript" text="link text" subject="The subject line"} And another: {mailto address="someone@domain.com" encode="javascript"} I have got some way with this but am falling down when it comes to optional capturing groups. The requirements for my regex are: The regex must match {mailto all the way through to } (because I want to ultimately remove the whole tag) The address parameter must exist, and I want to capture its contents: someone@domain.com The text parameter may exist, and I want to capture its contents if it does exist: link text The subject parameter may exist, and I want to capture its contents if it does exist: The subject line Thanks in advance!
  2. I like idea 1 - will explore that. Idea 2 I don't think is necessary - even technophobes know how to copy/paste text if they want to duplicate it.
  3. @joshuag, currently when an event has no start time or end time entered, Recurme populates "time" and "timeEnd" with "12:00 am". This makes it difficult to distinguish between events that have those fields empty (can often be the case for end time in particular) and events that happen to actually have 12:00 am entered as their start time or end time. Do you think you could populate "time" and "timeEnd" with "false" or something else recognisable if start time or end time is left empty for an event?
  4. Remove Blocks A textformatter module for ProcessWire that removes blocks of text/markup between configurable delimiters from output. This allows you to "comment out" blocks of text/markup so they remain present in the field but are not shown in the front-end output. This can be handy if content needs to be removed temporarily and will later be reinstated. Or you could use a commented block as a placeholder to indicate to an editor where some content should be added. Installation Install the Remove Blocks module. Configure the open and close delimiters if needed. The default open delimiter is {{ and the default close delimiter is }}. Tip: don't use delimiter characters that CKEditor will encode to HTML entities, e.g. >. Usage Add the Remove Blocks textformatter to one or more fields. Add the open and close delimiters around any content that you want to be removed from output. https://github.com/Toutouwai/TextformatterRemoveBlocks http://modules.processwire.com/modules/textformatter-remove-blocks/
  5. There is no hookable method especially for images inserted in a CKEditor field. But two options: 1. Use/code a textformatter module to manipulate the image tags within a field. This approach has the advantage that you don't have to mess around with your field settings to make sure the classes and attributes you want to add are allowed by ACF and HTML Purifier. There is even an existing textformatter module you can use: https://modules.processwire.com/modules/textformatter-srcset/ 2. Hook the saving of pages (e.g. Pages::saveReady) and modify the markup in your CKEditor field before it is saved. The approach would be similar to the textformatter option - you parse the markup to identify the image tags (using regex or a DOM parser such as DOM) and use the src attribute to get the relevant Pageimage to create your different sizes from. The difference is that this parsing/modification is done whenever the page is saved rather whenever the field value is loaded. Option 2 is more efficient, but I would tend to go for option 1 because it's not destructive and gives greater flexibility to make changes down the line. And maybe that existing textformatter module is just what you need.
  6. My vote goes for the status quo - no need to change output formatting or have an indicator IMO. I think the best thing is to get into the habit of always turning output formatting off before setting any value to a page (I tend to do it individually for the page I'm changing rather than for all pages). I think it's simplest to follow that rule everywhere - frontend, backend, in a module, etc. It's just a single line of code, and if output formatting is already off for any reason then it doesn't do any harm to explicitly set it off to be sure. If Tracy was to get involved in output formatting I think it would add confusion, particularly for new users who are still getting to grips with output formatting.
  7. Hooking ProcessPageSearch::findReady might be better because it's more specific to autocomplete and the method looks like it exists for just this sort of purpose. $wire->addHookAfter('ProcessPageSearch::findReady', function(HookEvent $event) { $selector = $event->arguments(0); // Manipulate $selector as needed... }); /** * Hookable function to optionally modify selector before it is sent to $pages->find() * * Not applicable when Lister is handling the search/render. * * #pw-hooker * * @param string $selector Selector that will be used to find pages * @return string Must return the selector (optionally modified) * */ public function ___findReady($selector) { return $selector; }
  8. PW cannot handle circular references in Page Reference fields: https://github.com/processwire/processwire-issues/issues/152 https://github.com/processwire/processwire-issues/issues/572
  9. I opened a request on GitHub: https://github.com/processwire/processwire-requests/issues/226 @Macrura, I noticed this post of yours from a while ago: Were you only able to achieve the data attributes by disabling HTML Purifier on the CKEditor field?
  10. Yes, but it can be set by anyone linking to your site, so I think it definitely needs to be verified. If you just display the event date from the GET variable without verifying it then any third party can create a link to your site that causes your event page to display any date of their choosing. I solved it like this: $req_date = $input->get->int('date'); $event = $recurme->find($req_date, $req_date, "id=$page->id")->first(); if(!$event) { // $req_date is invalid for this event // ... } rrule-gui.js needs updating in this package to account for the timeEndUnix property. Not quite. You are first passing the string through date()... // ... if(date('U',$date)){ $date = $date; } // ... ...which does not handle those example date strings correctly.
  11. The $dateFrom and $dateTo arguments aren't working with some date strings that are valid for strtotime(). // Not working $events = $recurme->find('01-08-2018', '31-08-2018'); // Also not working $events = $recurme->find('08/01/2018', '08/31/2018'); These are being converted by Recurme to the timestamp for "January 1 1970".
  12. @joshuag, is there a Recurme method to find the next n events, regardless of date? For example, if I want a listing showing the next 5 events. Another thing: the docs say that the $dateFrom and $dateTo arguments for the find() method are optional, but when I leave either of them out no events are returned. Edit: I worked this one out by looking at the module code. $dateFrom and $dateTo are set to today if not supplied (I was expecting no $dateFrom/$dateTo limits if not supplied). $events = $recurme->find(); // empty PageArray $events = $recurme->find('today'); // empty PageArray
  13. This is already possible since PW 3.0.87: https://processwire.com/blog/posts/pw-3.0.87/#new-field-template-context-settings
  14. @joshuag, when I do... $event = $recurme->event($page); ...where $page is a page with a Recurme field on it, I get the following notice: Undefined property: stdClass::$timeEndUnix in ...\site\modules\FieldtypeRecurme\MarkupRecurme.module:851 MarkupRecurme.module version 103. Is this the latest version? I think maybe you don't always bump up the version number as you make fixes? As I've mentioned to you previously via PM, when I purchased Recurme I never received a link to download the latest version so I'm always wondering if I'm using an older version with bugs that have already been fixed. Also, I think one area where the documentation needs more detail is how event data should be accessed when you are viewing an event page itself. For example, the calendar creates links to events like this: /path/to/eventpage/?date=1534366800 The date variable is a timestamp for the relevant date, but how is that to be used? Does the Recurme module use this so we can get the equivalent date somehow from $event? Or are we meant to just get that timestamp from $input and convert it to a date, in which case how do we validate that the timestamp is in fact a valid date for that event?
  15. Maybe you are just missing an echo? <div><?php echo $page->rockgrid; ?></div>
  16. $pages->find() returns a PageArray, and you can't get the URL of a PageArray. I think you want $pages->get() or $pages->findOne(). I recommend checking that a real page is returned before trying to get its URL. $p = $pages->findOne("template=categories-template, artcategories=2"); if($p->id) { // Page was found, output its URL, etc } else { // No page found, so deal with this somehow }
  17. Hi @adrian, What do you think about adding a "Expand/Collapse All" button for dumps? This button would expand/collapse all nested elements within a dump would be useful in situations where you are dumping a massive nested object and you want to use the browser's find tool to look for a specific string of text.
  18. When "Use HTML Purifier" is enabled for a CKEditor field any data-* attributes are stripped out. This happens regardless of the CKEditor ACF settings, and is pretty annoying considering how frequently data attributes are used/needed these days. I'd like to keep HTML Purifier activated but I want to change the configuration to allow specific data attributes. I know how to do this via addAttribute() - as mentioned here - and I can get this working if I directly edit MarkupHTMLPurifier::init() and clear the HTML Purifier cached files from /site/assets/cache/. public function init() { $this->settings->set('Cache.SerializerPath', $this->getCachePath()); $this->settings->set('Attr.AllowedRel', array('nofollow')); $this->settings->set('HTML.DefinitionID', 'html5-definitions'); $this->settings->set('HTML.DefinitionRev', 1); if($def = $this->settings->maybeGetRawHTMLDefinition()) { $def->addElement('figure', 'Block', 'Optional: (figcaption, Flow) | (Flow, figcaption) | Flow', 'Common'); $def->addElement('figcaption', 'Inline', 'Flow', 'Common'); // Added line below to allow data-ext attribute on 'a' elements $def->addAttribute('a', 'data-ext', 'Text'); } } But how can I change the configuration like this without modifying a core file? I want to set the configuration from a custom module. I don't see any hookable methods in MarkupHTMLPurifier but surely it must be configurable somehow. Does anyone know a way to do this?
  19. Not sure if it's just the result of the forum but when I paste your code above into the Tracy console I can see some unwanted hidden characters. When I remove those it works fine:
  20. I like this, but I think when you switch back to the first tab the dump should be expanded. Because in clicking the tab you are saying "show me this tab content", and if you are actually wanting to just reduce the height of the dump container you would click to collapse the dump on the current tab. Maybe a simplified way of handling this would be that clicking any tab a) shows that tab's content and b) toggles the collapsed state of the dump. So dumps in all tabs would be loaded collapsed by default, but clicking a tab also toggles open a collapsed dump so has the same effect as this latest update. It would also allow for an alternative way to collapse the dump on the current tab (i.e. clicking the active tab collapses/opens that dump depending on its current state).
  21. I don't think that colon is supposed to be at the end - that URL leads to a 404. Looks the URL should be https://insidemodernism.co.uk/feed/
  22. A little issue... Tracy Debugger v4.10.24 (working) Tracy Debugger v4.11.10
  23. Thanks for all the recent updates @adrian (and @tpr too). Is the "Use debugInfo() magic method" option redundant now? With this option unchecked I still see a populated Debug Info tab in the dumps panel. Also, do you think it would be possible to include a setting for which dump tab is active (or leftmost) by default, for those of us who most often want the Full Object and the Debug Info only once in a while?
  24. I can't reproduce that here. Do you have any modules installed that might be affecting the page list?
×
×
  • Create New...