HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Incoprating tool utilising PHP, JS & CSS

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#106024 (In Topic #20684)
Avatar

Fan in action

Where to now.

I have a relatively complex tool, a Child Support Calculator. The tool has been incorporated into an earlier version of OCP (V3 if I recall correctly) back in 2008 (my documentation written back then). 

According to my documentation. The CSS, HTML and Javascript are incorporated into a tpl file (FORM_PAGE_ADVANCED_CALCULATOR.tpl which is 1418 lines, approx 1000 lines of JS, 380 lines of CSS and the rest HTML and TP). This has been added as a theme (admin zone .. style .. themes) as advanced_calculator. The calculator is (meant to be) initiated by JS line that calls the main function (line 1415).

The JS basically gathers the user input although is quite complex as it has to cater with the dynamic management of input fields via the browser's Document Object Model (DOM).

I also have created a module named module_advanced_calculator.php (also have one named advanced_calculator.php) which defines a class named Module_advanced_calculator, this has been placed in advanced_calculator\pages\modules_custom.

The core php for the calculator has been placed into the sources_custom (this is only invoked by clicking on a button, so I very much doubt that anything is wrong with this or the includes). A folder for the inlcudes, named include has been created  in sources_custom and the included php files placed there.

Additionally a file (for annual changing data) has been included in sources_custom (this is a text file that is read in by the JS (via the line/code var amtawe_file = 'annual_changes.txt', XHOR = false; )to set a few values eg the years that the drop down year selection offers, the year selected then determines which other values are to subsequently be used). I know that there were originally issues with where this file was located (so this could be the issue but I would have thought that some message would have been issued).

I've tried adding the module via a page-link, this results in "PHP ERROR [1] Call to undefined function installadvanced_calculator66368_1() in sources\zones2.php(276) : eval()'d code on line 3 (version: 9.0.16, PHP version: 5.2.6, URL: /advanced_calculator/index.php?page=advanced_calculator)" and also a warning, after editing that "You have not defined any level 1 headings, which will impinge on your SEO, breadcrumbs, and web accessibility. You can easily make one in the WYSIWYG editor (write some text, and select ‘Heading 1’ from the format dropdown list), or via the Comcode 'title' tag. Advanced users can hide visually-undesired titles using CSS.".

I've also tried using {block="advanced_calculator" striptitle="1" onlyifpermissions="1" leave_page_and_zone="0" merge_parameters="0" use_breadcrumbs="0"}main_include_module{/block}in the page (square brackets changed to curly brackets to allow code to be shown here) this results in "There seemed to have been a loop of resource includes of param=advanced_calculator (e.g. a resource, such as a page, includes itself). The loop has been stopped so the server does not crash."

Without any code in the page I click on the zone and nothing noticeable happens (checking for HTML, CSS, Scripts using Firebug reveal that none of the code appears to have been read/processed).

Where am I going wrong?
What do I need to do?
Is this perhaps due to me basically utilising the version 3 method?

The site that I'm playing around with this is can be found at www.ocportal.ax.lt and here's the two files mentioned above.

A working version of the calculator within Ocportal can be found at http://www.familylawwebguide.com.au/cs/pg/advance_calculator

A non OCportal version also exists at http://www.csacalc.ath.cx/aCScalcv3.0.html
The calculator itself has been available since mid 2008.

Attachment
» Download: module_advanced_calculator.php (3 Kb, 94 downloads so far)
Attachment
» Download: FORM_PAGE_ADVANCED_CALCULATOR.tpl (51 Kb, 90 downloads so far)


Last edit: by Miket

Regards, Mike.
Back to the top
 
Posted
Rating:
#106027
Avatar

Try converting spaces tabs (3 spaces = 1 tab) and saving as a unix format text file. And/or stripping the empty uninstall/install functions.

ocPortal does some heavy optimisation when installing modules. Rather than loading the whole file (which may use a lot of memory when installing many modules at once), it just extracts the install/uninstall/info methods out of it. When it does this, it assumes ocPortal's coding conventions (regarding tabbing) have been followed, in order to do that efficiently.

Regarding the loop, it looks like perhaps some error is happening in the block call, and the block has been put in a place such that error screen also show the block (maybe a panel?). This makes it fall off trying to show an error. Try removing it from the panel and testing it in isolation on a test page.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#106033
Avatar

Fan in action

Chris, I think that I have solved it. Tried stripping all spaces and only using tabs, saving as unix, all to no avail other than helping me to cope better in what is summer here as I pulled the odd hair or two out :).

However, what I then did was to add a page to the zone and add the page to the zones menu. When selecting the menu option from the zone to go to the page the calculator appeared and is now working as expected.

So basically it appears that modules act on pages not zones. I did have to copy the invoked php from sources_custom to the zone's root directory and obviously also the includes.

I did have to do a get around as it was complaining that function get_page_title ( as in line $title=get_page_title(get_zone_name(),false); ) was missing. Just directly set $title.

I might do a little bit of a document on how I incorporated this.

Thanks for your suggestions and help.

Regards, Mike.
Back to the top
 
Posted
Rating:
#106036
Avatar

Didn't quite understand the above but it's late. Note: get_page_title->get_screen_title now.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#106037
Avatar

Fan in action

English SOH, pulled hairs out therefore head a little cooler in the hot weather down here due to less hair to keep heat in. :)

Solution, basically empty (pageless) zone doesn't invoke module. You need a page within a zone and then that page displays/runs the modules. Muggins (Me) was working with page-less zone.


Last edit: by Miket

Regards, Mike.
Back to the top
 
There are too many online users to list.
Control functions:

Quick reply   Contract

Your name:
Your message: