Jump to content

Search the Community

Showing results for tags 'Textformatter'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • Welcome to ProcessWire
    • News & Announcements
    • Showcase
    • Wishlist & Roadmap
  • Community Support
    • Getting Started
    • Tutorials
    • FAQs
    • General Support
    • API & Templates
    • Modules/Plugins
    • Themes and Profiles
    • Multi-Language Support
    • Security
    • Jobs
  • Off Topic
    • Pub
    • Dev Talk

Product Groups

  • Form Builder
  • ProFields
  • ProCache
  • ProMailer
  • Login Register Pro
  • ProDrafts
  • ListerPro
  • ProDevTools
  • Likes
  • Custom Development

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 20 results

  1. Soundmanager2 Audio for Processwire Github: https://github.com/outflux3/TextformatterSoundmanager Modules Directory: http://modules.processwire.com/modules/textformatter-soundmanager/ This module provides most of the free audio player interfaces for Soundmanager2 by Scott Schiller: Bar UI 360 UI 360+ spectrum UI mp3 buttons mp3 links Page Player, muxtape-style UI Cassette Player The module is a Textformatter that works by allowing you to insert shortcodes which are parsed into audio players. The players may be placed anywhere in the content (ck editor or other text field) using the shortcode, for example: [smplayer tag=audio1] The output will be a default single player (as specificed in the module settings), or if multiple audio files have the same tag, and you don't specify a type (UI), it will default to the Bar UI for the playlist. You may also specify page-player for the type as it also supports playlists. Here is a more complex tag: [smplayer tag=audio1 type=bar-ui color=2288CC] the tags available on shortcodes are: tag - *required to find the audio file on the page type (the type of player) limit (limit the number of files to load when using a playlist) Player specific tags for Bar UI: bar-ui (options for the bar-ui player) skin (applies to a bar-ui skin to load) extra (when set to true, it will display the extra controls) color (hex value for color - applies to bar-ui and mp3 buttons) compact (makes the player very narrow) playlist-open (make the playlist drawer open instead of needing to click the playlist button to open it.) dark-text (instead of white) flat (remove the faux 3d effect) When using the shortcode, you can chain the tags using underscore, for exmaple: [smplayer type=bar-ui bar-ui=flat_playlist-open_dark_text] Player specific tags for Cassette: cassette (options for the cassette player) In case you are not familiar with SM2, it powers a lot of major audio on the web, like Soundcloud, LastFM, AllMusic etc). The players are all rock solid and work on a wide range of browsers and devices. Features Multiple Audio Formats SM2 supports many formats, and those can be enabled/disabled in the module config if you want to prevent any from being loaded. So far this module was tested with MP3 and AAC (.m4a). GetID3 Support When enabled, ID3 tags from every audio file that pass through the Textformatter are read and cached as arrays using WireCache. Therefore the first load of a page with new audio files may be slow while the tags are read and stored. The tags are indexed by the filename of the audio, so as long as you don't upload multiple files with the same filename, or change the tags, the system will store the metadata permanently. To remove any metadata, you would need to use Soma's Cache Admin module, or clear it from the database. Schema Support When enabled, some schema tags relating to audio files will be added to the markup. CK editor Plugin Very basic dropdown that inserts some pre-configured player codes into the editor. Copy the plugin into your CK editor plugins folder, enable and add a button for 'soundmanager'. Instructions Before you install: 1) You will need a files field that accepts audio files, so set the extensions you want to use, such as mp3, m4a, mp4, wav etc. 2) Also make sure that you enable tags on the files field because the module references the tags for any audio file in the shortcode. 3) Add the files field to your template. Installation and Setup 1) Install the module and adjust your settings from the module configuration screen. 2) Add the TextformatterSoundmanager textformatter to the field where you want to insert audio (e.g. 'body'). 3) Optionally install the CK editor plugin to enable quick access to preconfigured shortcodes. 4) Add a shortcode into the textarea field that has the textformatter applied to. 5) You must reference the tag you entered in the audio file's tag field in the shortcode, and that will create a player for that audio file. 5a) To create a playlist, put the same tag in multiple audio files. Output 1) In order for the module to output the necessary styles and scripts, you need to echo the $config->styles and $config->scripts arrays into your site's header/footer. Here is an example: // In Header foreach($config->styles as $style) echo "<link rel='stylesheet' type='text/css' href='{$style}' />\n"; // In Footer foreach($config->scripts as $script) echo "<script type='text/javascript' src='{$script}'></script>\n"; API Usage To access the module's player method directly, you would first init the module in your _init.php file: $sm2 = $modules->get('TextformatterSoundmanager'); then anywhere in your templates, you can output any audio file with any player, in an configuration like this: $options = [ 'type' => 'bar-ui', 'skin' => 'gradient-fat', //'tag' => 'audio1', // tag is not needed when using the API //'bar-ui' => 'playlist-open' //all of the classes to apply to the bar ui. ]; foreach($page->audio as $track) { $content .= $sm2->player($track, $options); } Advanced Features Using other pages for storing music as playlists. You can create a field to hold a tag for a **page* and then refer to that tag in your shortcode. The shortcode word would be smplaylist instead of smplayer. The module will search the site for pages with that tag in that field. Then it will output all of the audio files in that page's audio field using the player and settings you specify. See the module configuration to select the tag field and adjust your shortcode words. Caveats Some player will not work well on the same page as other players. Bar UI and Page Player 360 Player and 360 Visual (large) players Also note that the cassette player can only occur once on a page. You can have multiple cassettes output, but they will all play the same audio file. The file that the cassette player uses is set in the script tag. In the future the setup may be modified to allow for cassette players to have their own audio files. About Soundmanager2 http://www.schillmania.com/projects/soundmanager2/ Speak and be heard More sound, in more places Despite being one of the senses, sound has largely been missing from the web due to inconsistent technology support. SoundManager 2 bridges this gap, making it easier to use audio across a growing variety of devices and platforms, both desktop and mobile. HTML5 + flash hybrid Complexity, reduced Supporting HTML5 audio can be tedious in modern browsers, let alone legacy ones. With real-world visitors using browsers ranging from mobile Safari to IE 6 across a wide range of devices, there can be many support cases to consider. SoundManager 2 gives you a single, powerful API that supports both new and old, using HTML5 audio where supported and optional Flash-based fallback where needed. Ideally when using SoundManager 2, audio "just works." The ginsu knife: 12 KB Big features, small footprint Performance is an important metric, too. SoundManager 2 packs a comprehensive, feature-rich API into as little as 12 KB over the wire when optimized; that's less than 8% of the original, uncompressed file size. SM2 is self-contained, having no external dependencies, and is compatible with popular JavaScript frameworks. The source code is BSD-licensed and is provided in fully-commented, non-debug and compiler-optimized "minified" versions appropriate for development and production use.
  2. TextformatterTypographer A ProcessWire wrapper for the awesome PHP Typography class, originally authored by KINGdesk LLC and enhanced by Peter Putzer in wp-Typography. Like Smartypants, it supercharges text fields with enhanced typography and typesetting, such as smart quotations, hyphenation in 59 languages, ellipses, copyright-, trade-, and service-marks, math symbols, and more. It's based on the PHP-Typography library found over at wp-Typography, which is more frequently updated and feature rich that its original by KINGdesk LLC. The module itself is fully configurable. I haven't done extensive testing, but there is nothing complex about this, and so I only envisage a typographical bug here and there, if any.
  3. As I mentioned in this issue, I've create a new textformatter for ParsedownExtraPlugin, which adds some oomph to your markdown. Repo: Parsedown Extra Plugin Unlike the built-in textformatter for Parsedown and Parsedown Extra, this should be used when you want to use Extra with additional configuration/customisation. Some examples: ### Test {.heading} - A [external link](https://google.com/){.google} with `google` as a class that opens in a new tab if the config property is set. - [Another link](/page){target=_blank} that opens in a new tab even though it isn't external. ```html .html <p>Test</p> ``` There's some config options available to you, such as setting attributes on all/external images and links, setting table and table-cell alignment classes, adjusting footnote classes and IDs, adding <code> attributes to their parent <pre> elements, and changing the <code> class if your syntax highlighter does not use language-*. I was thinking about adding the ability to make links open in a new tab by appending a plus to the link syntax, but only external links should be opening in a new tab anyway. Further, this would add extra, unnecessary processing time. Please let me know if you bump into any problems. ☺️
  4. Video or Social Post Embed Based on the TextformatterVideoEmbed module developed by Ryan Cramer, we have added the possibility to embed publications of the main social networks Facebook, Twitter and Instagram. ProcessWire Textformatter module that enables translation of YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu URLs to full embed codes, resulting in a viewable video or social post in textarea fields you apply it to. How to install Download or Clone from Github: https://github.com/lexsanchez/VideoOrSocialPostEmbed Copy the VideoOrSocialPostEmbed.module file to your /site/modules/ directory (or place it in /site/modules/VideoOrSocialPostEmbed/). Click check for new modules in ProcessWire Admin Modules screen. Click install for the module labeled: "Video or Social Post Embed". Now you will be on the module config screen. Please make note of the config options and set as you see fit. How to use Edit your body field in Setup > Fields (or whatever field(s) you will be placing videos in). On the details tab, find the Text Formatters field and select "Video or Social Post Embed". Save. Edit a page using the field you edited and paste in YouTube, Vimeo, Facebook, Twitter, Instagram and/or Issuu URLs each on their own paragraph. Example How it might look in your editor (like TinyMCE): How it works This module uses YouTube, Vimeo, Instagram, Facebook, Twitter and Issuu oEmbed services to generate the embed codes populated in your content. After these services are queried the first time, the embed code is cached so that it doesn't need to be pulled again. Configuration You may want to update the max width and max height settings on the module's configuration screen. You should make these consistent with what is supported by your site design. If you change these max width / max height settings you may also want to check the box to clear cache, so that YouTube/Vimeo/Facebook/Twitter/Instagram/Issuu oembed services will generate new embed codes for you. Using with Markdown, Textile or other LML This text formatter is looking for a YouTube, Vimeo, Instagram, Facebook, Twitter or Issuu video URL surrounded by paragraph tags. As a result, if you are using Markdown or Textile (or something else like it) you want that text formatter to run before this one. That ensures that the expected paragraph tags will be present when VideoOrSocialPostEmbed runs. You can control the order that text formatters are run in by drag/drop sorting in the field editor. Copyright 2018 by Ryan Cramer / Updated by Lex Sanchez
  5. Process Images A basic, proof-of-concept Textformatter module for ProcessWire. When the Textformatter is applied to a rich text field it uses Simple HTML DOM to find <img> tags in the field value and passes each img node through a hookable TextformatterProcessImages::processImg() method. This is a very simple module that doesn't have any configurable settings and doesn't do anything to the field value unless you hook the TextformatterProcessImages::processImg() method. Hook example When added to /site/ready.php the hook below will replace any Pageimages in a rich text field with a 250px square variation and wrap the <img> tag in a link to the original full-size image. For help with Simple HTML DOM refer to its documentation. $wire->addHookAfter('TextformatterProcessImages::processImg', function(HookEvent $event) { // The Simple HTML DOM node for the <img> tag /** @var \simple_html_dom_node $img */ $img = $event->arguments(0); // The Pageimage in the <img> src, if any (will be null for external images) /** @var Pageimage $pageimage */ $pageimage = $event->arguments(1); // The Page object in case you need it /** @var Page $page */ $page = $event->arguments(2); // The Field object in case you need it /** @var Field $field */ $field = $event->arguments(3); // Only for images that have a src corresponding to a PW Pageimage if($pageimage) { // Set the src to a 250x250 variation $img->src = $pageimage->size(250,250)->url; // Wrap the img in a lightbox link to the original $img->outertext = "<a class='lightboxclass' href='{$pageimage->url}'>{$img->outertext}</a>"; } }); GitHub: https://github.com/Toutouwai/TextformatterProcessImages Modules directory: https://processwire.com/modules/textformatter-process-images/
  6. hi there, is it possible to use a textformatter on a string/field in the template without applying it to an inputfield in the field settings? i searched the forum but didn't found any solution … thanks!
  7. This is a textformatter module that will automatically replace titles of other pages on your site with links to those pages. For example, if you have a template glossary-term, and mention the exact title of one page using that template in a textfield, the title will be automatically linked to that page (if the textfield uses that formatter). This is good for SEO, and saves you some manual labour. You can configure which templates should get automatically linked, and of course the formatter is only active for the fields you add this formatter to. Note that if you need more manual control over when and where titles are automatically linked, you're probably better of using Autolink from a Glossary by @mr-fan. Features Allows you to limit the automatic links by template. Only includes published & visible pages by default, with an option to include hidden pages. Automatically excludes the current page, with an option to change that behaviour. Allows you to configure the minimum title length for linked pages. Doesn't overwrite existing links, and detects most edge cases (titles inside other tag's attributes, titles inside existing links et c.). Supports multi-language sites. Titles will only be linked if a title in the current language is set. Can add configurable attributes to all automatically created links. This includes the ability to use page fields as replacement patterns for attributes. For example, you can create CSS classes that include the name of the template of the linked page. Extensive options and hooks to change the generated markup completely. Need <mark> elements with a title attribute based on a page field instead of a link? No problem. See the example project below. Prefer oldest or newest page in the case of duplicate titles. Queries the database directly for improved performance. Has options to switch between case sensitive and case insensitive modes, and force case sensitive behaviour even for case insensitive database collations. Allows you to overwrite the module configuration via the API to call the module with different settings for different requirements on the same site. Download & Documentation The module is now available in the modules directory: https://modules.processwire.com/modules/textformatter-page-title-links/ You can download & install it through the backend using the classname TextformatterPageTitleLinks. To install it manually, download or clone the module from the Github repository into your site/modules folder and install through the backend. The complete documentation can be found in the README in the repository. Make sure to check out the module configuration page after installing the module. Requirements PHP 7.1 or higher ProcessWire 3+ (it will probably work in older versions, I haven't tested those though). This is my first module, I hope it may become useful to some of you ? If you find any errors or have some other suggestions or feedback, let me know!
  8. File Info A textformatter module for ProcessWire. The module can add information to local Pagefile links in two ways: As extra markup before, within or after the link As data attributes on the link (handy if you want to use a Javascript tooltip library, for instance) Screenshots Module config Example of output Installation Install the File Info module. Add the textformatter to one or more CKEditor fields. Configuration Add markup action (and general) Select "Add markup to links" Select the Pagefile attributes that will be retrieved. The attribute "filesizeStrCustom" is similar to the core "filesizeStr" attribute but allows for setting a custom number of decimal places. If you select the "modified" or "created" attributes then you can define a date format for the value. Enter a class string to add to the links if needed. Define the markup that will be added to the links. Surround Pagefile attribute names in {brackets}. Attributes must be selected in the "Pagefile attributes" section in order to be available in the added markup. If you want include a space character at the start or end of the markup then you'll need >= PW 3.0.128. Select where the markup should be added: prepended or appended within the link, before the link, or after the link. Add data attributes action Select "Add data attributes to links" Select the Pagefile attributes that will be retrieved. These attributes will be added to the file links as data attributes. Attributes with camelcase names will be converted to data attribute names that are all lowercase, i.e. filesizeStrCustom becomes data-filesizestrcustom. Hook If you want to customise or add to the attributes that are retrieved from the Pagefile you can hook TextformatterFileInfo::getFileAttributes(). For example: $wire->addHookAfter('TextformatterFileInfo::getFileAttributes', function(HookEvent $event) { $pagefile = $event->arguments(0); $page = $event->arguments(1); $field = $event->arguments(2); $attributes = $event->return; // Add a new attribute $attributes['sizeNote'] = $pagefile->filesize > 10000000 ? 'This file is pretty big' : 'This file is not so big'; $event->return = $attributes; }); https://github.com/Toutouwai/TextformatterFileInfo https://modules.processwire.com/modules/textformatter-file-info/
  9. Textformatter for Google Maps https://github.com/teppokoivula/TextformatterGoogleMaps This module looks for Google Maps URLs (such as https://maps.google.fi/maps?safe=off&ie=UTF-8&q=disneyland,+paris) within paragraph (<p></p>) HTML tags and automatically converts them to embedded maps. Configurable options include embed type ("static" or "iframe"), API key, responsive embedding and Google Maps for Business settings. Other than that, it's pretty basic stuff. Original regexp for grabbing maps links was posted by Ryan (I believe) here on the forums, but I couldn't find that post anymore. I've altered it to better suit the needs of this module, added some configurable features (part of which, such as makeResponsive() method, are again based on Ryan's TextformatterVideoEmbed module) and so on. Hope someone finds it useful. (By the way: if you're going to use Google Maps for Business settings, please read the notes there carefully. Google doesn't exactly recommend storing your private key the way module settings are stored..)
  10. UPDATE: I have published a stable version of this module! Discussion thread: Github: https://github.com/MoritzLost/TextformatterPageTitleLinks --- Hello there, I'm working on a tiny textformatter module that searches the text for titles of other pages on your site and creates hyperlinks to them. I'm not sure if something like this exists already, but I haven't found anything in the module directory, so I wrote my own solution ? It's not properly tested yet and is still missing some functionality I would like to implement, so at the moment it should be considered in BETA. Features include limiting the pages that will get searched by template, and adding a custom CSS class to the generated hyperlinks. As I'm writing this I noticed that it will probably include unpublished and hidden pages at the moment, so yeah ... it's still in development alright ? You can download the module from Github: https://github.com/MoritzLost/TextformatterPageTitleLinks There's some more information in the readme as well. Anyway, let me know what you think! I'm happy about any feedback, possible improvements or ideas on how to improve the module. Cheers.
  11. 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/
  12. I just made a textformatter module that allows you to insert dummy content (lorem ipsum style) in text fields via shortcodes. Usage is simple - just type for example [dc3] into a textarea with this textformatter applied (plain textarea or CKEditor) and it will be replaced at runtime by 3 paragraphs of dummy content. It can also be used to populate text fields (for headings etc) using e.g. [dc4w]. This will produce 4 words (rather than paragraphs) at runtime. The actual content comes from an included 'dummytext.txt' file containing 50 paragraphs of 'Lorem ipsum' from lipsum.com. The 50 paragraphs is arbitrary - it could be 10 or 100 or anything in between, and the contents of that file can be changed for your own filler text if you wish. The slightly clever bit is that for any given page, the same content will be returned for the same tag, but the more paragraphs available in 'dummytext.txt', the less likely it is that two pages will get the same content (very roughly speaking - it's actually based on the page ID) so content selection is determinate rather than random, even though only the tags are saved to the db. Update Tags now work like this - [dc3] - Show 3 paragraphs ([dc:3], [dc3p] & [dc:3p] all do the same). [dc3-6] - Show 3 to 6 paragraphs randomly per page load ([dc:3-6], [dc3-6p] & [dc:3-6p] all do the same). [dc3w] - Show 3 words ([dc:3w] does the same). [dc3-6w] - Show 3 to 6 words randomly per page load ([dc:3-6w] does the same). <End update on tags.> If you think it might be useful, you can download it from GitHub and give it a try.
  13. Afternoon all, (or good morning or good night to those of you in other time zones) I am finally getting a chance to sink my teeth into ProcessWire (already purchased the Form Builder and ProFields) and I needed to make sure the output of one of my fields did not contain any curly quotes that my browser randomly changes regular quotes to when I'm editing the field. So I decided to try my hand at creating a Textformatter module to do just that. TextformatterReplaceCurlyQuotes is very simple but it's exciting for me to feel like I am contributing back to this great community. It was also nice for me to finally use my GitHub account as well...haha Anyway, I'm submitting it to the module directory and needed to post in a thread about it and here it is! http://modules.processwire.com/modules/textformatter-replace-curly-quotes/
  14. Hi there, I created a new module called TextformatterMixcloudEmbed. It is based on the Soundcloud Embed Textformatter by Marvin Scharle and the Textformatter Youtube Embed by Ryan and is working the same way. I hope you like it! Download: https://github.com/TomasKostadinov/TextformatterMixcloudEmbed Screenshots:
  15. I’m using the core-embedded TextformatterMarkdownExtra module, but I do not like the autolinking of URLs. Can it be turned off somehow, or do I have to install a custom Textformatter plugin which has this option turned off?
  16. While looking for a way to add target="_blank" to markdown formatted fields I came across these little gems in the TextformatterMarkdownExtra.module (in the wire>modules>textformatter folder, I'm running v3.0.33). Turns out someone (Ryan? Did you add this?) already thought of it: /** * A couple RCD extentions to MarkDown syntax, to be executed after Markdown has already had it's way with the text */ protected function markdownExtensions(&$str) { // add id attribute to a tag, when followed by a #myid if(strpos($str, '>#')) $str = preg_replace('/<([a-z][a-z0-9]*)([^>]*>.*?)(<\/\\1>)#([a-z][-_a-z0-9]*)\b/', '<$1 id="$4"$2$3', $str); // add class attribute to tag when followed by a .myclass if(strpos($str, '>.')) $str = preg_replace('/<([a-z][a-z0-9]*)([^>]*>.*?)(<\/\\1>)\.([a-z][-_a-z0-9]*)\b/', '<$1 class="$4"$2$3', $str); // href links open in new window when followed by a plus sign, i.e. [google](http://google.com)+ if(strpos($str, '</a>+')) $str = preg_replace('/<a ([^>]+>.+?<\/a>)\+/', '<a target="_blank" $1', $str); // strip out comments // if(strpos($text, '/*') !== false) $text = preg_replace('{/\*.*?\*/}s', '', $text); // if(strpos($text, '//') !== false) $text = preg_replace('{^//.*$}m', '', $text); } Adding: $f->addOption(self::flavorRCD, 'RCD extentions'); after line 107 of the file, adds an option field which you can handily check from the module's config screen in the admin. Now, the question I should have asked before doing this is: Does changing that have any detrimental effect on things I don't know about yet? : ) Would be great if someone with actual knowledge on this could chime in before I shoot myself in the foot (There must be a reason why this is not active by default?) Cheers guys! Phil
  17. I've written a textformatter module for transforming SoundCloud URLs into SoundCloud widgets. It is customizable, so the user is able to select color, auto-play and comment visibility options. Being based on the YouTube/Vimeo textformatter by Ryan, it is working in the same way. I hope you like it. TextformatterSoundcloudEmbed.module
  18. Hi guys, i've just a simple question of a little textformatter that i use for replacing different textvalues. I'm not that experienced PHP professional so i asking before i get in possible troubles... Setup is a "Glossar" like page holder with glossar_entries of various types like (abbr, internal link, external link) In my textfields i use pipes to set a term of that glossary like ||PW|| is great! i can preset ||Internal|| and ||External|| links and reuse them in every textblock...if i change the glossar entry on every page i use this it will automagic change... so far so simple (i've tested autolink and bought Profields...but i wanna give the user the power to edit this entries and have more control where these kind of autolinks work and could used) Here is my first more advanced textformatter on this and my simple question is - will this produce any overload or trouble if i get around about 0-10 terms on a content page? Second Question is on caching with textformatter replacements? How this is handled? <?php /** * ProcessWire TextformatterGlossary * * module made by mr-fan. * 15.09.15 basic class and wrapper configuration added * */ class TextformatterGlossary extends Textformatter { /** * getModuleInfo is a module required by all modules to tell ProcessWire about them * * @return array * */ public static function getModuleInfo() { return array( 'title' => 'Autolink from Glossar', 'version' => 101, 'author' => 'mr-fan', 'summary' => "Allows to use tags in textareas to autolink to specific glossary links." //'href' => 'http://processwire.com/talk/topic/1182-module-image-tags/?p=57160', ); } /** * Format the given text string. * * @param Page $page * @param Field $field * @param string $value */ public function formatValue(Page $page, Field $field, &$value){ // use fast strpos check to make sure that $value contains pipes || if (stripos($value, '||') === false) return; //get all terms in ||pipes|| in an array $matches = array(); preg_match_all('/\Q||\E[^|]+\Q||\E/', $value, $matches); //the multidimensional array holds the single strings in the second array['0'] foreach ($matches['0'] as $key => $match) { //get all glossary pages in a pagearray $entry = wire('pages')->find("template=glossar_item,title=$match")->first(); if ($entry) { //entry is found in our glossar pages //rip the pipes $term = str_replace('|', '', $match); //set the replacement depending from the item type switch ($entry->glossar_type) { case '1': //abbr $replacement = '<abbr title="' . $entry->headline . '">' . $term . '</abbr>'; break; case '2': //external link $replacement = '<a rel="help" target="blank" href="' . $entry->extern_link->url . '" data-original-title="' . $entry->headline . '"><span class="fa-globe" aria-hidden="true"></span> ' . $term . '</a>'; break; case '3': //internal link //internal link need to get the url $internLink = wire('pages')->get("$entry->page_link"); $replacement = '<a rel="help" href="' . $internLink->url . '" data-original-title="' . $entry->headline . '">' . $term . '</a>'; break; default: $replacement = $term; } //works the part inside the tags are changed ||test|| on every match $value = str_replace($match, $replacement, $value); } else { //the entry for ||term|| is not found and get renderd without pipes just as normal text //rip the pipes $term = str_replace('|', '', $match); //replace the matches of ||term|| with the cleaned value $value = str_replace($match, $term, $value); } } } } Best regards mr-fan
  19. I'm building a textformatter module and I would like to restrict it only to Text and Textarea fieldtypes. I can do it within the module logic and works fine, but is there a way to restrict in a way that it won't show in the admin where it is not supposed to appear? For example, "hide" it on a PageTitle field Details tab? Or is it the developer's task to decide?
  20. I'm a bit at a loss where to put my hooks. My requirement is to have a checkbox in the page (already there) that tells my module to pull fields (i.e. body, headline etc., but possibly others too in the near future) from the default language, no matter if there's a value set in the current language, and apply some replacement before rendering (think HannaCode-like, though with a whole dictionary database for technical terms behind it). Now, I'm unsure where to hook. I've looked through the LanguageSupport modules and tried to spy in HannaCode, but I've not been able to wrap my head around all the getLanguage..., getFormatted... and whatnot hookable methods involved. Attempts at overriding LanguageSupportFIelds::hookFieldtypeFormatValue and extending its logic somehow ended up with an endless recursion. If anybody could give me a few pointers (or method names) I should look for, this would be great.
  • Create New...