Jump to content
Robin S

HannaCodeDialog

Recommended Posts

@Macrura, glad you got it working eventually.

I intend to work on an upgrade to this module sometime soon. Hope to add a feature allowing all dialog options to be configured from within a single hook, which will make things easier (for those comfortable writing code anyway). Will also look at adding some clarification that an attribute must first be declared before adding any of the "double underscore" enhancements.

  • Like 3

Share this post


Link to post
Share on other sites

Hey @Robin S - using this for the first time and finding it awesome. Couple of quick questions:

Is there any easy way to prevent codes from being truncated in the dropdown?

Also, what's the best way to change the name of "Insert Hanna tag" - I see that they are translatable (via separate js files), but what's the suggestion for avoiding having changes overridden with module updates?

Thanks!

Share this post


Link to post
Share on other sites

Hi @adrian,

I just pushed an update that makes those strings translatable within the module file.

As for the other issue, if your tag name is long it can overflow the standard width that CKEditor applies to combo panels (I don't set any explicit width in this module). I could make a config field for panel width but I'd rather not because I think the default width is suitable in most cases and to get a dynamic value from PHP it would mean putting the CSS inline which is kinda ugly. Maybe you could just set your own width for the panel in some custom admin CSS?

.cke_combopanel__hannadropdown { width:300px !important; }

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks @Robin S - I sorted out the width with the Admin CSS feature of AOS. 

As for the translatable string - I'm a little unsure how to work with the recent change - I see you went from js language files to using PW's:

$this->_(

but wouldn't that mean I would need multi-language support installed to translate that? It's not a ML site, so that seems like an inefficient solution for me, but I am very tired, so might well be missing something here :)

Share this post


Link to post
Share on other sites
3 minutes ago, adrian said:

but wouldn't that mean I would need multi-language support installed to translate that?

You would need to install the LanguageSupport module but I don't think there's any inefficiency in doing that. You don't need to actually create any additional languages - you just edit the default language to override whatever strings you want. I believe that's the standard PW way for customising strings so I wouldn't want to reinvent the wheel and create configurable fields for every string.

  • Like 2

Share this post


Link to post
Share on other sites
1 minute ago, Robin S said:

you just edit the default language to override whatever strings you want

Yeah, you're probably right - I just haven't ever translated strings from a module before, but it sounds like it's easy - thanks!

Share this post


Link to post
Share on other sites

@adrian, I just pushed another update in v0.1.5 that will allow the dropdown label in the toolbar to adapt its width to the length of the text (in the case that it is translated).

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Robin S - I am seeing something weird where if I insert more than one code into a block of text. It all looks good until I save the page and then it reloads, and then all the text between the first and last code is highlighted in blue and connected so that's it no longer editable. Can you reproduce?

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Also wondering what you might think of an option to disable the dialog popup. For the needs of my current project I just want the dropdown for inserting the tags, but none of the tags have editable attributes so I think it would be preferable to not add the double-click handler on the inserted tags.

Share this post


Link to post
Share on other sites

Hi @adrian, I regularly use multiple Hanna tags within a single field and haven't seen that issue before.

It sounds like the closing delimiter of the first tag isn't being detected for some reason. I'm thinking that there must be some content in your tag that interferes with the detection of the closing delimiter. Does changing to a different Hanna tag delimiter fix it?

To debug you could try logging the "name" data attribute here, which should be the hanna tag contents without the delimiters.

Edit: actually, if it isn't matching the closing delimiter when the page reloads then it's probably related to the regex here. But it looks correct to me.

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, adrian said:

Also wondering what you might think of an option to disable the dialog popup.

I'm not aware of any way to do that. This module uses the widget component of CKEditor, and the dialog for that is defined once for all widgets in the CKEditor instance.

  • Like 1

Share this post


Link to post
Share on other sites
6 minutes ago, Robin S said:

To debug you could try logging the "name" data attribute here, which should be the hanna tag contents without the delimiters.

So this is what is being returned:

user_name]]. This is blah [[central_name

so it's removing the opening delimiters from the first tag. I have tried a few different delimiters with no luck so far. Any other thoughts?

Share this post


Link to post
Share on other sites

@adrian, sorry for the interlude - there was a power cut here. :o

Not sure if you saw the edit to my earlier post: if the widgets are correct when you close the dialog but incorrect when you reload the page then it's an issue with this regex. But it looks correct to me - the pattern should match any number of characters after an opening delimiter up until a closing delimiter. You probably know more about regex than me though - does the pattern look right to you?

  • Like 1

Share this post


Link to post
Share on other sites

Hey @Robin S - no worries - I hear things are a bit backwards in your part of the world :) BTW, I am a displaced Aussie - hope we can still be friends :)

Thanks for pointing me in the right direction. The issue is that regex is greedy.

You can see the problem here: https://regex101.com/r/ynCWrf/1 

Here is a non-greedy that works fine: https://regex101.com/r/1Qta6X/1

Thanks again for a great module.

  • Like 2

Share this post


Link to post
Share on other sites

@adrian, thanks for the regex fix! Applied in v0.1.6.

32 minutes ago, adrian said:

I hear things are a bit backwards in your part of the world

When I moved to the deep south I soon found out that a UPS is an essential piece of kit. And the irony is I'm only a short hop from the largest hydroelectric power station in NZ.

37 minutes ago, adrian said:

BTW, I am a displaced Aussie - hope we can still be friends

Why, of course :-). If you're feeling at all homesick, check out the trailer for this documentary I heard about yesterday:

A different kind of backwards...:-)

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, Robin S said:

If you're feeling at all homesick, check out the trailer for this documentary I heard about yesterday:

Wow - that's a depressing start to the day! The nasty side of Aussie culture - fortunately we're not all like that.

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, adrian said:

fortunately we're not all like that

Not at all. My partner and I had three weeks exploring NT's top end last winter and had nothing but good experiences. The Aussie grey nomad idea is genius - that's how I want to spend my retirement.

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, Robin S said:

Not at all. My partner and I had three weeks exploring NT's top end last winter and had nothing but good experiences. The Aussie grey nomad idea is genius - that's how I want to spend my retirement.

Hopefully we are still considered too young to be grey nomads, but we actually did that in May/June of last year, although we were roughing it in the back of a 4wd - no RV for us :) 

Great adventure through some amazing country!

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, adrian said:

we were roughing it in the back of a 4wd - no RV for us

Oh man, I want the best of both worlds - some of those pimped out Aussie 4WD campers are insane! Kiwis love their off-roading but I've never seen such amazing 4WDs until we went to the top end. Some folks have dropped some serious money on those. Proper go-anywhere Landcruisers with every conceivable mod-con built in. Love it.

  • Like 1

Share this post


Link to post
Share on other sites

This is about as far away from what we had as you can get, but this would be brilliant. He has a great series of videos!

 

 

  • Like 1

Share this post


Link to post
Share on other sites

Hey there,

anyone has an idea how to get the HannaDropdown running within a ProFields Table field?

I've got a reference to a FieldtypeTextarea with CKEditor where everything is working absolutely perfect, but the HannaDropdown won't show within the inline Editor of the table field.

Any clue? 🙂

Thanks,
Niko

Share this post


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

anyone has an idea how to get the HannaDropdown running within a ProFields Table field?

I've added support for CKEditor within a Table field in v0.1.10.

  • Like 2

Share this post


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

I've added support for CKEditor within a Table field in v0.1.10.

Holy shit! That was fast. Thank you very much, Robin!

  • Like 2

Share this post


Link to post
Share on other sites

Hey all, I've asked the question in Hanna Code module, but am a bit confused which one would make more sense to ask, so just to ask here as well. I've tested HC Dialogues and it worked like a charm for a complex new block with tabs, 2 types of posts etc. It is all done now, and I started adding some checks to see how the module would behave if some values are left empty. So my question is - is there any way to add an attribute requirement so that if it is set let's say as *required*, then you just can't leave the attribute with empty value or else. Presently to complete the functionality with no errors, I had to insert a few checks in the markup for empty "categories", empty values etc. If I could set (like I did with the attribute options) some requirements (can't be empty, cant be more than XXX words etc.) than the dialogue would just show some error and let you fill the data before it is pushed to CKEditor.

Any ideas how to achieve that or if it already exists, how to apply it?

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Robin S
      Repeater Images
      Adds options to modify Repeater fields to make them convenient for "page-per-image" usage. Using a page-per-image approach allows for additional fields to be associated with each image, to record things such as photographer, date, license, links, etc.
      When Repeater Images is enabled for a Repeater field the module changes the appearance of the Repeater inputfield to be similar (but not identical) to an Images field. The collapsed view shows a thumbnail for each Repeater item, and items can be expanded for field editing.
      Screencast

      Installation
      Install the Repeater Images module.
      Setup
      Create an image field to use in the Repeater field. Recommended settings for the image field are "Maximum files allowed" set to 1 and "Formatted value" set to "Single item (null if empty)". Create a Repeater field. Add the image field to the Repeater. If you want additional fields in the Repeater create and add these also. Repeater Images configuration
      Tick the "Activate Repeater Images for this Repeater field" checkbox. In the "Image field within Repeater" dropdown select the single image field. You must save the Repeater field settings to see any newly added Image fields in the dropdown. Adjust the image thumbnail height if you want (unlike the core Images field there is no slider to change thumbnail height within Page Edit). Note: the depth option for Repeater fields is not compatible with the Repeater Images module.
      Image uploads feature
      There is a checkbox to activate image uploads. This feature allows users to quickly and easily add images to the Repeater Images field by uploading them to an adjacent "upload" field.
      To use this feature you must add the image field selected in the Repeater Images config to the template of the page containing the Repeater Images field - immediately above or below the Repeater Images field would be a good position.
      It's recommended to set the label for this field in template context to "Upload images" or similar, and set the visibility of the field to "Closed" so that it takes up less room when it's not being used. Note that when you drag images to a closed Images field it will automatically open. You don't need to worry about the "Maximum files allowed" setting because the Repeater Images module overrides this for the upload field.
      New Repeater items will be created from the images uploaded to the upload field when the page is saved. The user can add descriptions and tags to the images while they are still in the upload field and these will be retained in the Repeater items. Images are automatically deleted from the upload field when the page is saved.
      Tips
      The "Use accordion mode?" option in the Repeater field settings is useful for keeping the inputfield compact, with only one image item open for editing at a time. The "Repeater item labels" setting determines what is shown in the thumbnail overlay on hover. Example for an image field named "image": {image.basename} ({image.width}x{image.height})  
      https://github.com/Toutouwai/RepeaterImages
      https://modules.processwire.com/modules/repeater-images/
    • By EyeDentify
      Hello There Guys.

      I am in the process of getting into making my first modules for PW and i had a question for you PHP and PW gurus in here.

      I was wondering how i could use an external library, lets say TwitterOAuth in my PW module.
      Link to library
      https://twitteroauth.com/

      Would the code below be correct or how would i go about this:
      <?PHP namespace ProcessWire; /* load the TwitterOAuth library from my Module folder */ require "twitteroauth/autoload.php"; use Abraham\TwitterOAuth\TwitterOAuth; class EyeTwitter extends WireData,TwitterOAuth implements Module { /* vars */ protected $twConnection; /* extend parent TwitterOAuth contructor $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token, $access_token_secret); */ public function myTwitterConnection ($consumer_key, $consumer_secret, $access_token, $access_token_secret) { /* save the connection for use later */ $this->twConnection = TwitterOAuth::__construct($consumer_key, $consumer_secret, $access_token, $access_token_secret); } } ?> Am i on the right trail here or i am barking up the wrong tree?
      I don´t need a complete solution, i just wonder if i am including the external library the right way.
      If not, then give me a few hint´s and i will figure it out.

      Thanks a bunch.

      /EyeDentify
    • By dimitrios
      Hello,
      this module can publish content of a Processwire page on a Facebook page, triggered by saving the Processwire page.
      To set it up, configure the module with a Facebook app ID, secret and a Page ID. Following is additional configuration on Facebook for developers:
      Minimum Required Facebook App configuration:
      on Settings -> Basics, provide the App Domains, provide the Site URL, on Settings -> Advanced, set the API version (has been tested up to v3.3), add Product: Facebook Login, on Facebook Login -> Settings, set Client OAuth Login: Yes, set Web OAuth Login: Yes, set Enforce HTTPS: Yes, add "http://www.example.com/processwire/page/" to field Valid OAuth Redirect URIs. This module is configurable as follows:
      Templates: posts can take place only for pages with the defined templates. On/Off switch: specify a checkbox field that will not allow the post if checked. Specify a message and/or an image for the post.
      Usage
      edit the desired PW page and save; it will post right after the initial Facebook log in and permission granting. After that, an access token is kept.
       
      Download
      PW module directory: http://modules.processwire.com/modules/auto-fb-post/ Github: https://github.com/kastrind/AutoFbPost   Note: Facebook SDK for PHP is utilized.


    • By kongondo
      FieldtypeRuntimeMarkup and InputfieldRuntimeMarkup
       
      Modules Directory: http://modules.processwire.com/modules/fieldtype-runtime-markup/
      GitHub: https://github.com/kongondo/FieldtypeRuntimeMarkup
      As of 11 May 2019 ProcessWire versions earlier than 3.x are not supported
      This module allows for custom markup to be dynamically (PHP) generated and output within a page's edit screen (in Admin).
       
      The value for the fieldtype is generated at runtime. No data is saved in the database. The accompanying InputfieldRuntimeMarkup is only used to render/display the markup in the page edit screen.
       
      The field's value is accessible from the ProcessWire API in the frontend like any other field, i.e. it has access to $page and $pages.
       
      The module was commissioned/sponsored by @Valan. Although there's certainly other ways to achieve what this module does, it offers a dynamic and flexible alternative to generating your own markup in a page's edit screen whilst also allowing access to that markup in the frontend. Thanks Valan!
       
      Warning/Consideration
      Although access to ProcessWire's Fields' admin pages is only available to Superusers, this Fieldtype will evaluate and run the custom PHP Code entered and saved in the field's settings (Details tab). Utmost care should therefore be taken in making sure your code does not perform any CRUD operations!! (unless of course that's intentional) The value for this fieldtype is generated at runtime and thus no data is stored in the database. This means that you cannot directly query a RuntimeMarkup field from $pages->find(). Usage and API
       
      Backend
      Enter your custom PHP snippet in the Details tab of your field (it is RECOMMENDED though that you use wireRenderFile() instead. See example below). Your code can be as simple or as complicated as you want as long as in the end you return a value that is not an array or an object or anything other than a string/integer.
       
      FieldtypeRuntimeMarkup has access to $page (the current page being edited/viewed) and $pages. 
       
      A very simple example.
      return 'Hello'; Simple example.
      return $page->title; Simple example with markup.
      return '<h2>' . $page->title . '</h2>'; Another simple example with markup.
      $out = '<h1>hello '; $out .= $page->title; $out .= '</h1>'; return $out; A more advanced example.
      $p = $pages->get('/about-us/')->child('sort=random'); return '<p>' . $p->title . '</p>'; An even more complex example.
      $str =''; if($page->name == 'about-us') { $p = $page->children->last(); $str = "<h2><a href='{$p->url}'>{$p->title}</a></h2>"; } else { $str = "<h2><a href='{$page->url}'>{$page->title}</a></h2>"; } return $str; Rather than type your code directly in the Details tab of the field, it is highly recommended that you placed all your code in an external file and call that file using the core wireRenderFile() method. Taking this approach means you will be able to edit your code in your favourite text editor. It also means you will be able to type more text without having to scroll. Editing the file is also easier than editing the field. To use this approach, simply do:
      return wireRenderFile('name-of-file');// file will be in /site/templates/ If using ProcessWire 3.x, you will need to use namespace as follows:
      return ProcessWire\wireRenderFile('name-of-file'); How to access the value of RuntimeMarkup in the frontend (our field is called 'runtime_markup')
       
      Access the field on the current page (just like any other field)
      echo $page->runtime_markup; Access the field on another page
      echo $pages->get('/about-us/')->runtime_markup; Screenshots
       
      Backend
       

       

       
      Frontend
       

×
×
  • Create New...