Jump to content
ryan

Hanna Code

Recommended Posts

5 hours ago, cjx2240 said:

Can I use Hanna Code in any field? Even a page title, or the title of a repeater? 

I have a site where someone wants to replace a snippet of text with an image wherever it appears, body, title, other text fields etc. - thinking this might be suitable.

You should be able to.  Just assign the Hannacode Textformatter to the fields of your choice and it should work.

  • Like 1

Share this post


Link to post
Share on other sites
18 hours ago, cjx2240 said:

Can I use Hanna Code in any field? Even a page title, or the title of a repeater? 

If you can add it on the Details tab as a Text Formatter, then it should work. Have you tried it? 😉

Share this post


Link to post
Share on other sites
1 hour ago, szabesz said:

If you can add it on the Details tab as a Text Formatter, then it should work. Have you tried it? 😉

I have, now! It worked a treat. The only consideration was that my title field was also being used to populate the <title> tag so I had to be a bit smarter, retain the original text that was being replaced in Hanna Code's replacement and strip tags in the page title.

  • Like 1

Share this post


Link to post
Share on other sites

I hope someone can help me with the issue I'm facing when using Hanna Code.

I've installed Hanna Code using the instructions and I've made a couple of Hanna Code's. For example: one HTML Hanna Code with an image, so that I can easily show the same image on different pages within the content, so I also can change it easily.

But right now, the results of the codes just doesn't show. Hanna Code shows them when I view the Hanna Code's preview, but the shortcode ( the [[name here]] codes) don't turn into something else. I've an example here: https://smartranking.nl/blog/oude-berichten-weer-hoger-in-google-laten-verschijnen/.

The shortcut remains "[[cta-seo-consult]]".

Is anyone known with this problem? How can I fix it? I hope someone can give me the solution for it. I already tried different text formatting, but that also doesn't help.

Share this post


Link to post
Share on other sites
23 minutes ago, jarik said:

I hope someone can help me with the issue I'm facing when using Hanna Code.

Welcome to the forums @jarik

Make sure you've enabled Hanna Code as a text formatter for the textarea field where you want it to work. I am in a bit of a hurry. Have a look at the settings of your textarea field (details tab). 

Edited by kongondo
clarification
  • Like 1

Share this post


Link to post
Share on other sites
51 minutes ago, kongondo said:

Welcome to the forums @jarik

Make sure you've enabled Hanna Code as a text formatter for the textarea field where you want it to work. I am in a bit of a hurry. Have a look at the settings of your textarea field (details tab). 

Here is an example of enabling Hanna Code on a textarea field (this one is called body):

hanna-code-texformatter1.thumb.png.ee8d25b336cfec6685741386f50cb1ba.png

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you very much for your reply! I feel a bit silly right now haha. Your solution worked, it's working now. Thanks!

Share this post


Link to post
Share on other sites

Hello gents.

I've been experimenting a lot lately with Hanna Code and Hanna dialogue which lead me to a full "News Block" code that can be inserted easily using CKEditor. My idea was to build a few similar news blocks and allow the admin to select the categories (represented by pages) for every block tabs etc.

Attached is a screen cast of what I have so far and it is working perfectly fine and as expected.

As usual, there is one HOWEVER 🙂 After some experimenting and adding few news pages (in my case as it is obvious some recipes), I was glad to see it all happening. The problem came, when I tried to insert the same Hanna Code block with the idea to show some different categories. What has happened is that the second block tabs came empty, but clicking on them started changing the navigation of the first one. From my humble experience with PHP I would guess that since Hanna code is using the same attributes, it affects the appearance of any other than the first block. So has any one ever came to a similar use and have found a solution that would allow to have multiple blocks inserted without an overlapping of the code of every one?

I am thinking about experimenting with inserting a random number after the block name which would be used for the tab number and tab content, however am not sure if there is a simpler or more elegant solution that I am missing yet...

Maybe it is important to mention that I am trying to accomplish a page builder using Hanna Code and Dialogue to allow selection of pages, add some limitations etc.

 

Spoiler

Screencast.gif

 

Share this post


Link to post
Share on other sites

Nevermind, looking at the code, I found the answer - every time I called the hanna code, the tabs were having identical names, so this was causing the issue. To fix it I've added a simple random string to the tab names and it is all working fine now.

 

	$permitted_chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
	$rand = substr(str_shuffle($permitted_chars), 0, 10);

	$tab_name = "Tab" . $count . "-" . $rand;

This gives me an alphanumeric string of 10 chars length which aims to avoid a chance of duplicating again the tab names. I know it might be an overkil, but just don't want to take the risk of generating random number and have them matching 😉 As of now, the tab ID is something like: #Tab1-wrf7te0Y2x

Share this post


Link to post
Share on other sites

Looking to use Hanna code with ProFields Table. Textformatter is not parsing the Hanna snippet. Can anyone give me the correct name of the formatter option since it needs to be manually added instead of selecting the TextFormatter option from the dropdown. 

 

Share this post


Link to post
Share on other sites

I use Hanna Code quite a lot, and especially with @Robin S's excellent dialog module. However, one thing I find a bit irritating is when you have lots of codes with php; the number of clicks to edit the php plus then needing to update the database (assuming you do this on a test version  before implementing live) is quite time consuming, often for quite trivial changes.

So: I am looking at re-engineering my codes along the following lines. Each code which needs php will just have the same code - something like

<?php
$result = hannaCode($input, $attr, $page, $hanna->name, $hanna->field, $hanna->value);
if (in_array('text', $result)) $hanna->value = $result['text'];
echo $result['out'];

Then, in a separate php file (probably "include"d  in init.php) I have a function 

hannaCode($input, $attr, $page, $hannaName, $hannaField, $hannaText)

with a switch on $hannaName to execute the code for that name.

This has 2 benefits:

  1. Any common code can go at the top, before the switch. E.g. I have 
    if ($page->template == 'admin') {
            $pId = $input->get('id');
            $page = wire('pages')->get($pId);
        }
        $helpArray = [
            'Property' => '[[Property]]: The name/title of the property (choose system name or title). Only works on a Booking page and its Mailing children',
    ..etc...
        ];
        if ($page->template == 'help-doc') {
            return ['out' => $helpArray[$hannaName]];
        }
    switch ...

     

  2. I can do simple edits in the IDE, test and upload without having to touch the database.

Has anyone else tried this. Any thoughts? Is it even worth a tut?

Share this post


Link to post
Share on other sites

@MarkE, if you prefer to edit your Hanna code in your IDE you might find this useful:

 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks - that looks neat. I guess I could then just have another function for the common elements.

Share this post


Link to post
Share on other sites
8 hours ago, Pixrael said:

Thanks. That’s useful, in that it has no database component, but I really need a drop-down/dialog capability so I think I’ll have to stick with the “hybrid” route, where only standard code is in the back-end. 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   1 member

  • Similar Content

    • By MoritzLost
      This module allows you to integrate hCaptcha bot / spam protection into ProcessWire forms. hCaptcha is a great alternative to Google ReCaptcha, especially if you are in the EU and need to comply with privacy regulations.

      The development of this module is sponsored by schwarzdesign.
      The module is built as an Inputfield, allowing you to integrate it into any ProcessWire form you want. It's primarily intended for frontend forms and can be added to Form Builder forms for automatic spam protection. There's a step-by-step guide for adding the hCaptcha widget to Form Builder forms in the README, as well as instructions for API usage.
      Features
      Inputfield that displays an hCaptcha widget in ProcessWire forms. The inputfield verifies the hCaptcha response upon submission, and adds a field error if it is invalid. All hCaptcha configuration options for the widget (theme, display size etc) can be changed through the inputfield configuration, as well as programmatically. hCaptcha script options can be changed through a hook. Error messages can be translated through ProcessWire's site translations. hCaptcha secret keys and site-keys can be set for each individual inputfield or globally in your config.php. Error codes and failures are logged to help you find configuration errors. Please check the README for setup instructions.
      Links
      Github Repository and documentation InputfieldHCaptcha in the module directory (pending approval) Screenshots (configuration)

      Screenshots (hCaptcha widget)

       
       

       
    • By joshua
      This module is (yet another) way for implementing a cookie management solution.
      Of course there are several other possibilities:
      - https://processwire.com/talk/topic/22920-klaro-cookie-consent-manager/
      - https://github.com/webmanufaktur/CookieManagementBanner
      - https://github.com/johannesdachsel/cookiemonster
      - https://www.oiljs.org/
      - ... and so on ...
      In this module you can configure which kind of cookie categories you want to manage:

      You can also enable the support for respecting the Do-Not-Track (DNT) header to don't annoy users, who already decided for all their browsing experience.
      Currently there are four possible cookie groups:
      - Necessary (always enabled)
      - Statistics
      - Marketing
      - External Media
      All groups can be renamed, so feel free to use other cookie group names. I just haven't found a way to implement a "repeater like" field as configurable module field ...
      When you want to load specific scripts ( like Google Analytics, Google Maps, ...) only after the user's content to this specific category of cookies, just use the following script syntax:
      <script type="text/plain" data-type="text/javascript" data-category="statistics" data-src="/path/to/your/statistic/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing" data-src="/path/to/your/mareketing/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="external_media" data-src="/path/to/your/external-media/script.js"></script> <script type="text/plain" data-type="text/javascript" data-category="marketing">console.log("Inline scripts are also working!");</script> The type has to be "optin" to get recognized by PrivacyWire, the data-attributes are giving hints, how the script shall be loaded, if the data-category is within the cookie consents of the user. These scripts are loaded asynchronously after the user made the decision.
      If you want to give the users the possibility to change their consent, you can use the following Textformatter:
      [[privacywire-choose-cookies]] It's planned to add also other Textformatters to opt-out of specific cookie groups or delete the whole consent cookie.
      You can also add a custom link to output the banner again with a link / button with following class:
      <a href="#" class="privacywire-show-options">Show Cookie Options</a> <button class="privacywire-show-options">Show Cookie Options</button> This module is still in development, but we already use it on several production websites.
      You find it here: PrivacyWire Git Repo
      Download as .zip
      I would love to hear your feedback 🙂
      CHANGELOG
      0.1.1 Debugging: fixed error during uninstall 0.1.0 Added new detection of async scripts for W3C Validation 0.0.6 CSS-Debugging for hiding unused buttons, added ProCache support for the JavaScript tag 0.0.5 Multi-language support included completely (also in TextFormatter). Added possibility to async load other assets (e.g. <img type="optin" data-category="marketing" data-src="https://via.placeholder.com/300x300">) 0.0.4 Added possibility to add an imprint link to the banner 0.0.3 Multi-language support for module config (still in development) 0.0.2 First release 0.0.1 Early development
    • By bernhard
      --- Please use RockFinder3 ---
    • By MoritzLost
      Cacheable Placeholders
      This module allows you to have pieces of dynamic content inside cached output. This aims to solve the common problem of having a mostly cacheable site, but with pieces of dynamic output here and there.  Consider this simple example, where you want to output a custom greeting to the current user:
      <h1>Good morning, <?= ucfirst($user->name) ?></h1> This snippet means you can't use the template cache (at least for logged-in users), because each user has a different name. Even if 99% of your output is static, you can only cache the pieces that you know won't include this personal greeting. A more common example would be CSRF tokens for HTML forms - those need to be unique by definition, so you can't cache the form wholesale.
      This module solves this problem by introducing cacheable placeholders - small placeholder tokens that get replaced during every request. The replacement is done inside a Page::render hook so it runs during every request, even if the response is served from the template cache. So you can use something like this:
      <h1>Good morning, {{{greeting}}}</h1> Replacement tokens are defined with a callback function that produces the appropriate output and added to the module through a simple hook:
      // site/ready.php wire()->addHookAfter('CachePlaceholders::getTokens', function (HookEvent $e) { $tokens = $e->return; $tokens['greeting'] = [ 'callback' => function (array $tokenData) { return ucfirst(wire('user')->name); } ]; $e->return = $tokens; }); Tokens can also include parameters that are parsed and passed to the callback function. There are more fully annotated examples and step-by-step instructions in the README on Github!
      Features
      A simple and fast token parser that calls the appropriate callback and runs automatically. Tokens may include multiple named or positional parameters, as well as multi-value parameters. A manual mode that allows you to replace tokens in custom pieces of cached content (useful if you're using the $cache API). Some built-in tokens for common use-cases: CSRF-Tokens, replacing values from superglobals and producing random hexadecimal strings. The token format is completely customizable, all delimiters can be changed to avoid collisions with existing tag parsers or template languages. Links
      Github Repository & documentation Module directory (pending approval) If you are interested in learning more, the README is very extensive, with more usage examples, code samples and usage instructions!
    • By Craig
      I've been using Fathom Analytics for a while now and on a growing number of sites, so thought it was about time there was a PW module for it.
      WayFathomAnalytics
      WayFathomAnalytics is a group of modules which will allow you to view your Fathom Analytics dashboard in the PW admin panel and (optionally) automatically add and configure the tracking code on front-end pages.
      Links
      GitHub Readme & documentation Download Zip Modules directory Module settings screenshot What is Fathom Analytics?
      Fathom Analytics is a simple, privacy-focused website analytics tool for bloggers and businesses.

      Stop scrolling through pages of reports and collecting gobs of personal data about your visitors, both of which you probably don't need. Fathom is a simple and private website analytics platform that lets you focus on what's important: your business.
      Privacy focused Fast-loading dashboards, all data is on a single screen Easy to get what you need, no training required Unlimited email reports Private or public dashboard sharing Cookie notices not required (it doesn't use cookies or collect personal data) Displays: top content, top referrers, top goals and more
×
×
  • Create New...