Robin S Posted June 26, 2016 Share Posted June 26, 2016 On 24/06/2016 at 1:08 PM, Robin S said: I'd be keen to hear if there is a better way to get pages into a PageArray while maintaining a given order of page IDs. Maybe $pages->getById() is the way to go. $my_pages = $pages->getById([1086,1021,1053,1018]); Link to comment Share on other sites More sharing options...
jsantari Posted August 10, 2016 Share Posted August 10, 2016 I have some hanna codes that I would like to trigger the inclusion of css and js files depending on the code that is used. Does PW have a way to do this similar to WordPress wp_enqueue_script or style core functions? Link to comment Share on other sites More sharing options...
Robin S Posted August 11, 2016 Share Posted August 11, 2016 In /site/init.php... $config->css_files = new \ProcessWire\FilenameArray(); $config->js_files = new \ProcessWire\FilenameArray(); In your Hanna Code PHP... $config->css_files->add('/site/templates/path/to/file.css'); $config->js_files->add('/site/templates/path/to/file.js'); Wherever you output your <head>... foreach($config->css_files as $css_file) { echo "<link rel='stylesheet' href='$css_file'>"; } foreach($config->js_files as $js_file) { echo "<script src='$js_file'></script>"; } See the code for the FilenameArray methods available: prepend(), remove(), removeAll(), etc. P.S. you can use the existing core $config->styles and $config->scripts FilenameArrays but other files might be added to these by certain modules so cleaner to create your own FilenameArrays I think. 6 Link to comment Share on other sites More sharing options...
jsantari Posted August 11, 2016 Share Posted August 11, 2016 Thanks - that looks like what I need. Link to comment Share on other sites More sharing options...
spacemonkey95 Posted September 21, 2016 Share Posted September 21, 2016 It's occurred to me that adding to this existing thread might have been the better option for seeking a solution to my problem. I've already created a new thread so I wonder if it's ok to post a link to it here in case anyone who might know the answer will be more likely to see it here... Link to comment Share on other sites More sharing options...
Robin S Posted September 22, 2016 Share Posted September 22, 2016 1 hour ago, spacemonkey95 said: It's occurred to me that adding to this existing thread might have been the better option for seeking a solution to my problem. I think there might be still better places to ask. Table is a Pro field with it's own dedicated support sub-forum. And the feature you are describing is not a feature of Hanna Code but rather a feature of the Hanna Code Helper module. 1 Link to comment Share on other sites More sharing options...
spacemonkey95 Posted September 22, 2016 Share Posted September 22, 2016 Hi Robin, Thanks for the reply. You're right, of course. I was getting myself muddled up and I'd forgotten the Table is a Profield. Link to comment Share on other sites More sharing options...
ottogal Posted October 26, 2016 Share Posted October 26, 2016 Hi all, I'm struggling with a problem which is more a PHP issue than one of Hanna Code. <?php ?> <audio controls> <source src='<?= $audiofile?>' type='audio/mp3'> </audio> This little HC works fine when used in a textarea/CKEditor field like this: [[audio file="/site/assets/files/1234/foo.mp3"]] Now I wanted to make it flexible and enable the editor user to insert the path to any mp3 file (stored on some page in a field "mp3" of type File, allowed file extension mp3). In the HC Attributes I set a default value for $file, defining file=LINK . Now the editor, inserting the HC using the HannaCodeHelper Module, gets [[audio file="LINK"]] The aimed workflow for the editor user was: Double click on LINK to mark it and using the Link button of the CKEditor to choose the wanted file from the wanted page. Obviously, the value created by CKE had to undergo some treatment. Of course it's a link from which I had to extract the value of the href attribute (here /site/assets/files/1122/bar.mp3) , but because of the double quotes from [[audio file="LINK"]] it would become "<a href="/site/assets/files/1234/foo.mp3">" where the second " would terminate the string. I tried string functions str_replace(), strstr() etc. but to no avail. Perhaps I could have used Javascript, but I wanted to find a PHP solution. Could anyone help on that? Link to comment Share on other sites More sharing options...
Robin S Posted October 26, 2016 Share Posted October 26, 2016 @ottogal An easy solution would be to change... [[audio file="LINK"]] ...to... [[audio file='LINK']] If you want Hanna Code Helper to insert single quotes around attributes I think you'll have to modify the module code. Change line 124 to: $attrs .= " $attrName='$attrValue'"; You can use SimpleXML in your Hanna Code to get the href from the link: $a = new SimpleXMLElement($file); $path = $a['href']->__toString(); 1 Link to comment Share on other sites More sharing options...
ottogal Posted October 27, 2016 Share Posted October 27, 2016 @Robin S 15 hours ago, Robin S said: If you want Hanna Code Helper to insert single quotes around attributes I think you'll have to modify the module code. Change line 124 to: $attrs .= " $attrName='$attrValue'"; Good find, thank you! After this change even my simple use of the function strstr() works - to crop the string on both ends, setting free the href attribute value: <?php $f = (string) $file; $f = strstr($f,'/site'); $audiofile = strstr($f,'">',true); ?> <audio controls> <source src='<?= $audiofile?>' type='audio/mp3'> </audio> Your second hint to use SimpleXMLElement() of course is a cleaner way to do it: <?php $a = new SimpleXMLElement($file); $audiofile = $a['href']->__toString(); ?> <audio controls> <source src='<?= $audiofile?>' type='audio/mp3'> </audio> Didn't know this class before - so again I learnt something new. Thanks a lot again! Link to comment Share on other sites More sharing options...
Sergey Voronov Posted November 3, 2016 Share Posted November 3, 2016 Good day. I really liked the Hana Code Insert plugin. But I was faced with the following problem. In WordPress platform there are 5 roles: Administrator, Editor, Author, Contributor, Subscriber. I want only the Administrator could work with this plugin. How to limit access to this plugin for role Contributor ? Sorry, for my bad English. Link to comment Share on other sites More sharing options...
adrian Posted November 3, 2016 Share Posted November 3, 2016 1 minute ago, Sergey Voronov said: Good day. I really liked the Hana Code Insert plugin. But I was faced with the following problem. In WordPress platform there are 5 roles: Administrator, Editor, Author, Contributor, Subscriber. I want only the Administrator could work with this plugin. How to limit access to this plugin for role Contributor ? Sorry, for my bad English. Check out the hanna specific permissions and only assign them to the contributor role. Link to comment Share on other sites More sharing options...
Sergey Voronov Posted November 3, 2016 Share Posted November 3, 2016 If I understand correctly, you need to edit the code in the plugin ? Link to comment Share on other sites More sharing options...
adrian Posted November 3, 2016 Share Posted November 3, 2016 4 minutes ago, Sergey Voronov said: If I understand correctly, you need to edit the code in the plugin ? No - just go to your PW Access > Roles menu and assign the relevant hanna permissions to the appropriate roles. I just re-read your question and see that you actually only want the codes editable by the administrator role. By this do you mean the PW superuser role? By default, only the superuser should be able to view/edit hanna codes. 1 Link to comment Share on other sites More sharing options...
Sergey Voronov Posted November 3, 2016 Share Posted November 3, 2016 I have installed wordpress version 4.5.3. Please tell me where I need to go and what to do? Please explain the steps Or show a screenshot Link to comment Share on other sites More sharing options...
adrian Posted November 3, 2016 Share Posted November 3, 2016 Just now, Sergey Voronov said: I have installed wordpress version 4.5.3. Please tell me where I need to go and what to do? Please explain the steps Or show a screenshot I think you're in the wrong place - this is the support forum for ProcessWire, not Wordpress! ProcessWire also has a hanna code plugin - I think that is your confusion, but since you are here, maybe you should stay 2 Link to comment Share on other sites More sharing options...
Sergey Voronov Posted November 3, 2016 Share Posted November 3, 2016 Thank you! Sorry. Now I understand Please tell me where can help me to solve my problem? Link to comment Share on other sites More sharing options...
adrian Posted November 3, 2016 Share Posted November 3, 2016 I haven't used the Wordpress hana plugin, but maybe this is what you are looking for: http://wpmarketing.org/forum/forum/wp-plugin-hana-code-insert 1 Link to comment Share on other sites More sharing options...
Sergey Voronov Posted November 3, 2016 Share Posted November 3, 2016 Thank You very much! Goodbye Link to comment Share on other sites More sharing options...
szabesz Posted November 8, 2016 Share Posted November 8, 2016 On 6/24/2016 at 3:08 AM, Robin S said: I'd be keen to hear if there is a better way to get pages into a PageArray while maintaining a given order of page IDs. Probably not: Link to comment Share on other sites More sharing options...
Robin S Posted November 8, 2016 Share Posted November 8, 2016 7 hours ago, szabesz said: On 24/06/2016 at 1:08 PM, Robin S said: I'd be keen to hear if there is a better way to get pages into a PageArray while maintaining a given order of page IDs. Probably not: I answered my own question in the next post: On 26/06/2016 at 8:09 PM, Robin S said: Maybe $pages->getById() is the way to go. $my_pages = $pages->getById([1086,1021,1053,1018]); The situation @Wanze replied to is a little different - not an order of page IDs but an order of values to match a field against. 1 Link to comment Share on other sites More sharing options...
Battman Posted January 11, 2017 Share Posted January 11, 2017 I like this module, I used similar plugin in Wordpress before I switched to PW, so I was happy to find it. Regarding the code editor, a helper module would be very useful which could save and reload the scrolling and cursor position when saving the code, so I could continue the editing where I left it. I'm not sure where, but I found something similar, but I don!t remember exactly. I tried to search in Google again and in this forum also, but no success. Maybe it was a different editor ... Can anyone suggest a solution? Thanks! Link to comment Share on other sites More sharing options...
adrian Posted January 11, 2017 Share Posted January 11, 2017 1 minute ago, Battman said: Regarding the code editor, a helper module would be very useful which could save and reload the scrolling and cursor position when saving the code, so I could continue the editing where I left it. I'm not sure where, but I found something similar, but I don!t remember exactly. I tried to search in Google again and in this forum also, but no success. Maybe it was a different editor ... I use that technique in the Console Panel of the TracyDebugger module - it's pretty easy to implement by storing the current position in LocalStorage or cookie. Perhaps you could send Ryan a PR with the added functionality? Link to comment Share on other sites More sharing options...
Battman Posted January 11, 2017 Share Posted January 11, 2017 3 hours ago, adrian said: I use that technique in the Console Panel of the TracyDebugger module - it's pretty easy to implement by storing the current position in LocalStorage or cookie. I checked TracyDebugger and I like it, thanks for the suggestion! As I see, it uses Ace editor also, so your solution can be implemented in the Hanna code modul too. Can you give me more details, how you did that? Link to comment Share on other sites More sharing options...
adrian Posted January 11, 2017 Share Posted January 11, 2017 5 minutes ago, Battman said: I checked TracyDebugger and I like it, thanks for the suggestion! As I see, it uses Ace editor also, so your solution can be implemented in the Hanna code modul too. Can you give me more details, how you did that? Save position: https://github.com/adrianbj/TracyDebugger/blob/865a669a3ddfc0e528413452235e8aefe50e332e/ConsolePanel.inc#L95-L107 Restore position: https://github.com/adrianbj/TracyDebugger/blob/865a669a3ddfc0e528413452235e8aefe50e332e/ConsolePanel.inc#L540-L545 Link to comment Share on other sites More sharing options...
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