louisstephens Posted October 14, 2020 Posted October 14, 2020 After a whiIe of not using the module I recently ran into an issue when I reinstalled the hanna code module. I tried uninstalling the module and reinstalling it, but then I run into the issue of: SQLSTATE[HY000]: General error: 1813 Tablespace '`revamp`.`hanna_code`' exists. I checked the database with adminer and searched for "hanna_code", but I am not seeing any tablespace in the database. Is there a way of clearing this out so I can do a fresh install? Also, I was going to use this module to allow people to define the form fields they would like to use in a setup I am currently developing (one per line). For example, they could type in [[form-firstname]] and the output would be: <input type="text" name="firstname" id="firstname" required> <label for="firstname" class="is-required">First Name</label> In my infinite wisdom, I thought I could explode by the line and wrap each input into a column/row. Obviously this doesnt work as the output is actually two lines (and some of my hanna codes would output up to 6 lines). Is there a good way to go about adding in rows/columns to the actual inputs?
rash Posted November 24, 2020 Posted November 24, 2020 Is it possible to pass session vars immediately in Hanna Code? Let’s say, I include two PHP files file_1.php and file_2.php via Hanna Code input in a textarea. When I set $session->foo = "bar" in file_1.php and try to get the value in file_2.php it is not there before page reload. Obviously it has to do with the rendering/formatting order. Is there a more or less dirty trick to intrude the session vars into Hanna Code in the first run?
mel47 Posted November 29, 2020 Posted November 29, 2020 Hi, I know this module have not changed since many years, but could I suggest to add a description for each Hanna code? I come back to my setup page and have some codes that I didn't update since years and I don't know why/where they used through my website. I would like to have written a small description. Yes, you could tell me I should have written comments in the code itself, and it's what I would do starting from now... ? But something on the setup page will be faster to read. Thanks! 4
kongondo Posted November 30, 2020 Posted November 30, 2020 On 11/29/2020 at 5:59 AM, mel47 said: but could I suggest to add a description for each Hanna code? Not exactly what you are describing but maybe Robin's module could be of help? At least for editors. It can do captions.
Spica Posted February 13, 2021 Posted February 13, 2021 I am using an custom attribute. But it gets rendered with a tag. When I bd($vid) the output is </code>508075620<code> The value 508075620 is correct. I had to strip the tags manually. But would like to know whats going on.
gmclelland Posted April 14, 2021 Posted April 14, 2021 @JFn - see https://github.com/ryancramerdesign/ProcessHannaCode/issues/23
JFn Posted April 15, 2021 Posted April 15, 2021 18 hours ago, gmclelland said: @JFn - see https://github.com/ryancramerdesign/ProcessHannaCode/issues/23 Although the issue is closed, I commented on it, since it's the same error but not the same resolution or offending module installed.
adrian Posted April 15, 2021 Posted April 15, 2021 13 minutes ago, JFn said: Although the issue is closed, I commented on it, since it's the same error but not the same resolution or offending module installed. The old version of @Robin S's HannaCodeDialog module also called that method: https://github.com/Toutouwai/HannaCodeDialog/blob/7ea31c31f151fbe3ea1982c83ac94dfa209e763e/HannaCodeDialog.module#L175 Update to the latest version of that and you should be fine.
JFn Posted April 15, 2021 Posted April 15, 2021 After a second look, apparently the offending HannaCodeHelper module was installed, although I don't recall installing it, was it part of the previous version by default? Anyway, disabling it, no more errors, problem solved. 1
adrian Posted April 15, 2021 Posted April 15, 2021 3 minutes ago, JFn said: was it part of the previous version by default? Nope ?
JFn Posted April 15, 2021 Posted April 15, 2021 Just now, adrian said: Nope ? Oh my, I must be getting old ☺️. That's the thing with processwire, you set it and forget it, it just keeps on running ?
sz-ligatur Posted April 28, 2021 Posted April 28, 2021 I have trouble with latest update v0.3.0 – my hanna code stops working. In v0.2.0 I could use #1: wire("pages")->get($someid) – in v0.3.0 it throws error "Call to undefined function wire()". It's easily fixed by calling $pages->get($someid) instead - but I wonder why it's now the opposite as it was in v0.2.0 where I couldn't use $pages? #2: Inside the hanna code I call custom functions defined in _func.php (included @ready.php – I once moved the include from site/_init.php to ready.php to be able to use the shared functions in hanna code). That worked with v0.2.0, now in v0.3.0 I receive the same error as above "Call to undefined function myFunction()"s I guess I've got something basically wrong here… I have no clue how to get my custom functions work inside hanna code. Anybody can shed a light … ? ProcessWire: 3.0.165 PHP: 7.4.11
Ivan Gretsky Posted April 29, 2021 Posted April 29, 2021 I guess it is namespace related. Try adding ProcessWire namespace in you Hanna codes.
sz-ligatur Posted April 29, 2021 Posted April 29, 2021 2 hours ago, Ivan Gretsky said: I guess it is namespace related. Try adding ProcessWire namespace in you Hanna codes. Ah, I forgot to mention it, I tried already – adding <?php Namespace Processwire; doesn't change anything…
adrian Posted April 29, 2021 Posted April 29, 2021 Try calling the function like: \ProcessWire\myFunction()
sz-ligatur Posted April 30, 2021 Posted April 30, 2021 On 4/29/2021 at 3:40 PM, adrian said: Try calling the function like: \ProcessWire\myFunction() …ah… thank you adrian! I rember seeing that before. The whole change from v0.2.0 to v0.3.0 is kind of nebulous for me… I should read about namespacing I guess. And it works! I namespaced all my hanna codes now, changed all wire('…') to $…-> and prefixed my custom function calls as you mentioned.
MarkE Posted September 6, 2021 Posted September 6, 2021 On 4/29/2021 at 9:34 AM, Ivan Gretsky said: Try adding ProcessWire namespace in you Hanna codes. On 4/29/2021 at 2:40 PM, adrian said: Try calling the function like: \ProcessWire\myFunction() I am confused by this. Surely it should not be necessary to both add the namespace in the Hanna code AND call the function \ProcessWire\myFunction()? So I looked at the TextFormatterHannaCode.module - getPHP() method and found this: $php = '<' . '?php'; $openPHP = $php; $openPHPNS = "$php namespace ProcessWire;"; $firstLine = 'if(!defined("PROCESSWIRE")) die("no direct access");'; if(strpos($code, 'namespace') && preg_match('/(namespace\s+ProcessWire(?:;|\s*;))/', $code, $matches)) { $openPHP = $openPHPNS; $code = str_replace($matches[1], '', $code); } if(strpos($code, $openPHP) !== 0 && strpos($code, $php) !== 0) { // prepend open PHP tag to code if not already present $code = "$openPHP\n$firstLine\n$code"; } else { // otherwise insert our $firstLine security check $code = str_replace($openPHP, "$openPHP\n$firstLine\n", $code); } It seems that the method is removing "namespace ProcessWire;" from the Hanna code. Looking at the cached files shows this to be the case. In other words, adding "namespace ProcessWire;" to the Hanna code is pointless as \ProcessWire\myfunction() is still going to be needed. I really don't know why the above code has been added or what it is trying to achieve? 1
MarkE Posted September 6, 2021 Posted September 6, 2021 On 9/6/2021 at 9:12 AM, MarkE said: I really don't know why the above code has been added or what it is trying to achieve? The more I look at this, the more it seems to me to be a bug. The current method has the effect of not only removing the namespace, but also failing to add: if(!defined("PROCESSWIRE")) die("no direct access"); to the Hanna code. In my case, I have dozens of Hanna codes all just calling one hannaCode() function, so that I can maintain the codes in my IDE rather than the PW UI (much less time-consuming!). The upgrade seems to require me to edit every single Hanna code, which surely ought not to be the intention. I have therefore hacked my TextFormatterHannaCode.module to include the following in getPHP(): $php = '<' . '?php'; $openPHP = $php; $openPHPNS = "$php namespace ProcessWire;"; $firstLine = 'if(!defined("PROCESSWIRE")) die("no direct access");'; if(strpos($code, 'namespace') && preg_match('/(namespace\s+ProcessWire(?:;|\s*;))/', $code, $matches)) { $openPHP = $openPHPNS; $code = str_replace($matches[1], '', $code); } if(strpos($code, $openPHP) !== 0 && strpos($code, $php) !== 0) { // prepend open PHP tag to code if not already present $code = "$openPHPNS\n$firstLine\n$code"; } else { // otherwise insert our $firstLine security check $code = str_replace($php, "$openPHPNS\n$firstLine\n", $code); } This automatically adds the namespace and the 'die' to all Hanna codes and works (so far) for me. Perhaps others ( @adrian, @ryan?) might suggest a better fix or tell me that I've got it all wrong ? EDIT: I have raised an issue on GitHub for this
MarkE Posted January 7, 2022 Posted January 7, 2022 The namespace issue still seems to be unresolved. I think that is also related to this. I would be grateful for any comments on the GitHub issue I raised and whether I should just raise a PR to get @ryan’s attention?
MarkE Posted March 29, 2023 Posted March 29, 2023 @ryan - this still seems to be open. I assume the intention is not to add the namespace if it isn't in the hanna PHP code, otherwise it should be added and so should the 'die'. I think, in that case, the fix is simple - replace the line `$code = str_replace($openPHP, "$openPHP\n$firstLine\n", $code);` by `$code = str_replace($php, "$openPHP\n$firstLine\n", $code);` The existing line does not work because, if namespace was in the code it has been removed, but $opnPHP includes it, so the str_replace does not operate. I have created a PR for this ----------------- If you do not have namespace declarations in your hanna code php and need them, then the following executed in Tracy console seems to do the trick: $h = $modules->get('TextformatterHannaCode'); $codes = $h->hannaCodes(); $codesAll = $codes->getAll(); foreach($codesAll as $code) { $codeString = $code->code; if(!strpos($codeString, 'namespace')) { $codeString = str_replace('?php', '?php namespace ProcessWire;', $codeString); } $code->code = $codeString; $codes->save($code); }
JayGee Posted December 15, 2023 Posted December 15, 2023 Are people still actively using Hanna Code? I'm trying to do an install of it on a site for the first time in a while. Hitting a problem getting the module to install. The text formatter will install, but not the Hanna Code module meaning I don't get the editor (even with the config added or site in debug ?).
Tiberium Posted December 15, 2023 Posted December 15, 2023 9 hours ago, JayGee said: Are people still actively using Hanna Code? yes. Without problems. On which Processwire version are you?
JayGee Posted December 15, 2023 Posted December 15, 2023 2 hours ago, Denis Schultz said: yes. Without problems. On which Processwire version are you? It was on latest stable 3.0.229. Updating to latest dev 3.0.231 seem to resolve it. For clarity I'm doing to work updating a fairly old site - so I can't 100% say it isn't something in the legacy code or a Handover from the older PW version I updated from.
MarkE Posted July 26, 2024 Posted July 26, 2024 I have a site with a large number of Hanna codes which I want to use on another site. How can I do this without manually exporting and importing each one?
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now