Iam using 7.1.1 and I have this code:
how to turn the following code into a language key. It contains a table that uses javascript functions for sorting and creation of the table.
<link href="../YUI/2.6.0/build/fonts/fonts-min.css" rel="stylesheet" type="text/css" /> <link href="../YUI/2.6.0/build/datatable/assets/skins/sam/datatable.css" rel="stylesheet" type="text/css" /> <script src="../YUI/2.6.0/build/yahoo-dom-event/yahoo-dom-event.js" type="text/javascript"></script> <script src="../YUI/2.6.0/build/element/element-beta-min.js" type="text/javascript"></script> <script src="../YUI/2.6.0/build/datasource/datasource-min.js" type="text/javascript"></script> <script src="../YUI/2.6.0/build/datatable/datatable-min.js" type="text/javascript"></script>
echo "</br><div id='yuidatatable1190152'> <table width='100%' id='yuidatatable1190152_src'> <thead> <tr> <th>Type</th> <th><strong>Frequency</strong></th> <th><strong>Length</strong></th> <th><strong>Physician</strong></th> <th><strong>Current</strong></th> </tr> </thead> <tbody>"; $exercise = mysql_query("SELECT * FROM exercise WHERE user_id = '$client'"); while ($row_exercise = mysql_fetch_array($exercise)) { $Type = $row_exercise["ExcType"]; $Frequency = $row_exercise["ExcFreq"]; $Length = $row_exercise["ExcLength"]; $Concern = $row_exercise["ExcConcern"]; $Current = $row_exercise["current"];
echo "<tr> <td> $Type</td> <td> $Frequency</td> <td> $Length</td> <td> $Concern</td> <td> $Current</td> </tr>"; $row_count++; } echo "</table> </div>"; ?> <script type="text/javascript"> // BeginWebWidget YUI_DataTable: yuidatatable1190152 (function() { var cn = document.body.className.toString(); if (cn.indexOf('yui-skin-sam') == -1) { document.body.className += " yui-skin-sam"; } })(); var inityuidatatable1190152 = function() { var yuidatatable1190152_columnDef = [ {key:"type",label:"Type",sortable:true}, {key:"frequency",label:"Frequency",sortable:true}, {key:"length",label:"Length",sortable:true}, {key:"concern",label:"Concern",sortable:true}, {key:"current",label:"Current",sortable:true} ]; this.parseNumberFromCurrency = function(sString) { return parseFloat(sString.substring(1)); }; this.yuidatatable1190152_DS = new YAHOO.util.DataSource(YAHOO.util.Dom.get("yuidatatable1190152_src")); this.yuidatatable1190152_DS.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; this.yuidatatable1190152_DS.responseSchema = { fields: [ {key:"type"}, {key:"frequency"}, {key:"length"}, {key:"concern"}, {key:"current"} ] }; var yuidatatable1190152 = new YAHOO.widget.DataTable("yuidatatable1190152", yuidatatable1190152_columnDef, this.yuidatatable1190152_DS); function columnSort() { } yuidatatable1190152.subscribe("columnSortEvent", columnSort) }; // Create the YUI DataTable when the HTML document is usable. YAHOO.util.Event.onDOMReady(inityuidatatable1190152); // EndWebWidget YUI_DataTable: yuidatatable1190152 </script>
The section in orange, I have added to the _header.html page, and so far it is working perfectly. My first question is: Can I put the remaining code into a language key.
I have included a pic of what the tables look like in their entirety. (on the right - i keep forgetting these dual screens show up in my screenshots)
caredesign.net |
No. As far as i know language keys cannot contain and do not process php code.
https://www.deanbassett.com |
okay - thats what i thought, i tried but was hoping i was doing something wrong. So, how can i take the code section in orange - javascript - and make it so that i dont have to put that code every place I want to put the tables. One catch though, "yuidatatable1190152" the 1190152 is different for each table. caredesign.net |
That depends on where it is going to appear. But you also don't want the code on pages that are not going to contain the table. If the table is going to be in a page block, then you make that part of the page block.
https://www.deanbassett.com |
i was hoping there would be a cleaner way to do it, but in the pic i added earlier - that page block in the center alone has 8 of those tables - thus why i am looking for a cleaner/better way to do the tables. caredesign.net |
You may want to study up on dolphins service calls.
You could place everything needed into a class file in the classes folder. Then in a php block you would just use a service call. The service call could be written to accept parameters so a different table is generated based on what was passed.
Service calls are how a lot of modules provide blocks on other pages. For example the shoutbox can be placed on any page via a simple service call in a php block. The shoutbox module generates the actually shoutbox code and returns it to be displayed in the block.
Not sure how advanced you are in dolphin coding yet, but you may want to look into it.
https://www.deanbassett.com |
well, thanks to the forums here, my understanding of dolphin is getting better. Unfortunately, I do not know how to do service calls, but just knowimg that I can achieve what i want is a great start - thanks again for your unending knowledge caredesign.net |
I had a module developer on here explain service calls to me; I wanted to modify a block that was only on the home page to be on the account page and change the function slightly so that the account page showed different data than the home page; and it does. Let me get something together and I will PM it to you. Geeks, making the world a better place |
cool, thanks GG - i wasnt going to work on this now. Was going to come back to it later once i got everything else done. it works as it is now, but I have a future plan - one that already has me wanting to jump off of a bathroom sink and take a swan dive into my toilet- lol.
And knowing how to do those service calls wil be a great enhancement to my coding skills.
caredesign.net |
I'm curious... Why aren't you using a jquery plugin instead of YUI? I can't help but think you'll run into some weird js conflict by mixing two different libraries. You might be able to lighten the additional cod a bit if you stick with jquery. My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
when I created the very first site - that is the code i used because it allows for sorting of columns and such - and it worked. Now, this was also done 2 years ago and I have been lugging this huge bit of code from site to site.
If there is an easier and cleaner way to do it - I am fair game. Ijust dont know how - and I have been using that YUI table for years now.
caredesign.net |
Just a quick clarification. In my original screenshot, i miscounted, there are 12 different tables - lets say tables 1 through 12. Now,table 1 is on 8 different pages, table 2 is on 6 different pages, tabloe 3 is on 5 different pages, and - you get the idea. The page in my screenshot shows all of the tables. (just cut off )
My original thought is along the same lines as a language key - cause i can create a short key, put all the info in that key, and then put just the key where i want it to be to show what I want to show. Deanos helped me already on putting more than 3 variables in a key, and all is well there.
So under the same concept, I was looking for a way to do the same thing with the tables. That way I can clean up my php coding as well as make it more efficient - if there is such a thing.
Hope that explanation works
caredesign.net |
@HL - i just checked out the link you posted, and just wanna say Thanks for screwing me - roflmfaop - just kiddiing - well, kinda. No, seriously, i looked at the sample and it looks great. I even like the number per page shown and the pagination at the bottom.
Problem is - once I use this in one place, I know the person I am working with is going to want to change everything to reflect how that table is designed. And I really dont want to go through and change every table - there are only the 12 that I need to change. But after dealing with this guy for 5 years I kinda know how he thinks and what he is going to want once he sees the new table.
Ugh - why does progress have to be so backwards.
caredesign.net |
just another quick thought/question - could I create the tables in their own php page, and then use a require_once or an include to show the table on the page and in the spot I want it to show? caredesign.net |
RE:
@HL - i just checked out the link you posted, and just wanna say Thanks for screwing me - roflmfaop - just kiddiing - well, kinda. No, seriously, i looked at the sample and it looks great. I even like the number per page shown and the pagination at the bottom.
Problem is - once I use this in one place, I know the person I am working with is going to want to change everything to reflect how that table is designed. And I really dont want to go through and change every table - there are only the 12 that I need to change. But after dealing with this guy for 5 years I kinda know how he thinks and what he is going to want once he sees the new table.
Ugh - why does progress have to be so backwards.
Glad I could throw a monkey wrench into your machine. Even if jquery and yui play well together, it's a pretty good bet that your code will be more efficient if you stick with one js library.
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
RE:
just another quick thought/question - could I create the tables in their own php page, and then use a require_once or an include to show the table on the page and in the spot I want it to show?
Don't see why not.
<div id="tableID">
<?php include('table.php'); ?>
</div>
My opinions expressed on this site, in no way represent those of Boonex or Boonex employees. |
I think that would be the simplest way HL. And again, Thanks Deanos. Once I get everything else situated, I will go back and learn about those service calls. Cause it was those that gave me the idea of just using an include for the tables. I will have to take the time out to learn how to do it the dolphin way.
Thanks Deanos
Thanks HL
Thanks GG
All 3 of you have helped me tremendously.
caredesign.net |