help with design

Archived from the Xataface Users forum.

compudude86 — Fri Sep 15, 2006 11:20 am

ok, i need help here, i want my dataface to work like an online mysql query browser of sorts, i want the entire base to be displayed, not just one line a page. how do i do this, or is there a tutorial that would point me in the right direction, ive already done the “create your first application” so thats where im at.


shannah — Fri Sep 15, 2006 12:41 pm

Hi Joe,

I’m glad to help.. i’m not sure I fully understand the request yet though. Is it that you want to display all of the records in the table as a list? How would this be different than the “list” tab view?

Best regards

Steve


compudude86 — Sat Sep 16, 2006 4:00 pm

hi steve,
ok, right now, its displaying just a single line from my table until i hit “next”, then it displays the next item on my table, i want it in a list format, but im not sure how to program my app to do this. thanks


Aoirthoir — Sat Sep 16, 2006 4:11 pm

Can you post your table structure here? (In mysql type show create table tablename

I had this problem when I tried running dataface at first. It turned out I did not have a Primary Key field. Do you have a primary key field? Usually you want it to be autoincrement. I use the following code to add an auto increment to a table that does not have one…you may have to change it to suit your needs. For instance if you have more than about 16 million records in any table that you are trying to add this to, you need to change mediumint in the code below to int (4 billion records) or bigint (9 quintillion records). Usually mediumint is enough though.

Here is the code:
ALTER TABLE TABLENAME ADD ID MEDIUMINT( 8 ) UNSIGNED ZEROFILL NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ;

Don’t know if dataface still requires something like this though. I think mysql technically does, though you can add tables and records without it anyhow.


shannah — Sat Sep 16, 2006 10:31 pm

Is this in the “list” tab that you are seeing this. You are describing what sounds like the “Details” tab. Correct me if I’m wrong.

Certainly Dataface supports both list and details view, so I’m not sure I fully understand the situation.

-STeve


compudude86 — Mon Sep 18, 2006 6:47 am

yep, it was because there was no primary key, it all works now, but how would i hide this key from view?


compudude86 — Mon Sep 18, 2006 7:24 am

also, my dataface is showing up as text only, its not showing any of the tabs or styles or anything…any possibility as to what is wrong?


Aoirthoir — Mon Sep 18, 2006 7:50 am

For the first request, two things you have to do to hide a field

In your apps directory add a directory called tables then add a directory for each tablename like so:

myapp/tables/TableName
myapp/tables/OtherTableName

If you are running your app in windows the capitalization does not matter. But in OSX and Linux it will matter. So if your table name has caps in MySQL make sure they are the same in the folders. Even in windows I do this, just in case I move the structure to a Linux system.

Then in each table directory create a file called fields.ini. In fields ini to hide your ID field do this:

[ID]
widget:type = hidden
visibility:list = hidden

This must be done for each table you have. We’ve discussed a global fields.ini in the past. Hopefully it can be implemented soon. Then you would only need it in your apps folder.


Next the issue with it showing up as text and no tabs or styles is a CSS issue. Make sure that your index.php has the following code:

require_once ‘/FILESYSTEM_path_to_dataface/dataface/dataface-public-api.php’;

ON WINDOWS THIS MIGHT LOOK LIKE ‘C:\Program Files\XAMPP\htdocs\dataface.0.6.3r2\dataface-public-api.php’;

ON LINUX THIS MIGHT LOOK LIKE ‘/home/yourusername/somedirectory/dataface.0.6.3r2/dataface-public-api.php’;
// include the initialization file

df_init(__FILE__, ‘DOMAIN/dataface/’);
// initialize the site

This might be as simple as ‘somedomain/dataface.0.6.3r2/’);

or even better if dataface is stored directly in a folder on root in your server ‘/dataface/’);

or lets say you store all your libraries in a lib folder then it would be ‘/lib/dataface/’)

The key here is to understand that you want to give a RELATIVE path if at all possible to dataface. This is relative from your apps URL. Thus if your app is www.mygreatdatafaceapp.com/rolodex/ then the dataface might be www.mygreatdatafaceapp.com/dataface/ or just /dataface/ or something similar. Whatever the name of your dataface folder is.

However, let us say you were storing your dataface on another domain such as www.mygreatlibraries.com... And your app was still on www.mygreatdatafaceapp.com. Well you could still access dataface from ‘www.mygreatlibraries.com/dataface/’); but some parts of it like the FCKeditor and CSS would probably be broken.

So try that first..make sure your dataface app and your dataface directory are on the same domain. Then make sure you point to it that way…and lastly make sure that you give the exact SYSTEM folder to dataface.

Hope that helps


compudude86 — Mon Sep 18, 2006 7:58 am

ok, to the file paths, my web is set up like this

/www/
|
|—dataface
|
|
|—-book
|
|-index.php

so how would my path go?


compudude86 — Mon Sep 18, 2006 8:05 am

i shouldve mentioned thats (filesystem root)/var/www


Aoirthoir — Mon Sep 18, 2006 9:06 am

Ok this is probably what you need:

require_once ‘(filesystem root)/var/www/dataface/dataface-public-api.php’;
// include the initialization file
df_init(__FILE__, ‘/dataface’);
// initialize the site

Which would become I believe:
require_once ‘/var/www/dataface/dataface-public-api.php’;
// include the initialization file
df_init(__FILE__, ‘/dataface’);
// initialize the site

Now the df_init line I am mostly sure on….but not 100% sure. I am making the assumption here that /var/www is your web server root…where documents are served from. If that is indeed the case it should probably be listed as above. Then you do not have to worry about pointing to the actual domain of dataface. Give that a try and let us know.


shannah — Mon Sep 18, 2006 9:16 am

Just want to emphasize that the only line that will need to be changed to solve this problem is the df_init() line. If you change your df_init() call to look like Joseph’s example above, it shoud pick up the stylesheet.

-Steve


Aoirthoir — Mon Sep 18, 2006 9:19 am

That’s right. I should have realized if dataface was running, then the first line didnt need to be changed. Sorry bro.


compudude86 — Mon Sep 18, 2006 10:03 am

ah, got it!!! thanks for your help, and trust me, youll be seeing a lot more of me around here!!


Aoirthoir — Mon Sep 18, 2006 10:14 am

Oh no! not another joe

Look forward to it bro. Glad we could help.


Aoirthoir — Mon Sep 18, 2006 9:06 am

Ok this is probably what you need:

require_once ‘(filesystem root)/var/www/dataface/dataface-public-api.php’;
// include the initialization file
df_init(__FILE__, ‘/dataface’);
// initialize the site

Which would become I believe:
require_once ‘/var/www/dataface/dataface-public-api.php’;
// include the initialization file
df_init(__FILE__, ‘/dataface’);
// initialize the site

Now the df_init line I am mostly sure on….but not 100% sure. I am making the assumption here that /var/www is your web server root…where documents are served from. If that is indeed the case it should probably be listed as above. Then you do not have to worry about pointing to the actual domain of dataface. Give that a try and let us know.


shannah — Mon Sep 18, 2006 9:16 am

Just want to emphasize that the only line that will need to be changed to solve this problem is the df_init() line. If you change your df_init() call to look like Joseph’s example above, it shoud pick up the stylesheet.

-Steve


Aoirthoir — Mon Sep 18, 2006 9:19 am

That’s right. I should have realized if dataface was running, then the first line didnt need to be changed. Sorry bro.


compudude86 — Mon Sep 18, 2006 10:03 am

ah, got it!!! thanks for your help, and trust me, youll be seeing a lot more of me around here!!


Aoirthoir — Mon Sep 18, 2006 10:14 am

Oh no! not another joe

Look forward to it bro. Glad we could help.


compudude86 — Mon Sep 18, 2006 10:26 am

actually, one last question on here, from now on ill start new threads, but here goes:
i have a few fields, which when a formula is applied, gives me a percentage. now, in mysql, i use a view to do this, but when i point dataface to the view, it shows zeros. i want my dataface to have a column, “GPM”, to display the otuput, like so:

(SRP-NETBTL) / SRP

and i want it to have a rounded number, with a following percent sign. any help would be appreciated


shannah — Mon Sep 18, 2006 10:45 am

Hi Joe,

This feature is not well tested but you can give it a shot.
http://framework.weblite.ca/documentation/how-to/how-to-add-calculated-fields-to-your-list-and-details-view

It is also possible to add calculated fields in the delegate class, but these wouldn’t automatically show up on the details or list view. They would just be available to you at an API level.


compudude86 — Wed Sep 20, 2006 8:17 am

ok, so how would i go about doing it? i read it and im just really confused on it


shannah — Wed Sep 20, 2006 8:54 am

You would add a line to the beginning of your fields.ini file as follows:

Code: Select all
__sql__ = "select *, (SRP-NETBTL)/SRP as GPM from tablename"

As I said, I haven’t tested very thoroughly, but it should add a GPM column to your list view and details view.

Best regards

Steve


compudude86 — Wed Sep 20, 2006 9:31 am

ok, its fine, i guess ill be the test subject then, is there a way to make the column a (19,0) like you would in sql? and how would you add a percent sign to the end of it?


shannah — Wed Sep 20, 2006 9:52 am

Use the mysql FORMAT function to display the number to the correct decimal places, and use the CONCAT function to prepend a dollar sign.

e.g.
__sql__ = “select *, CONCAT(‘$’,FORMAT((SRP-NETBTL)/SRP),2) as GPM from tablename”

Or some variation on that… Check the mysql string functions manual page for more info about FORMAT and other functions that would be useful in this regard.

Hope this helps.

-Steve


Aoirthoir — Wed Sep 20, 2006 10:43 am

Playing around with this, it seems, this is only for calculated totals? It cannot be used to just include a field from another table into your table?

For instance I have two tables. Customer. Return. Customer has an ID which is contained within Returns as CustID. In the Returns list and view screens, would I be able to display the Customer name by setting up a Customer.ID = Return.CustID ?

This is what I tried from the code posted above..but clearly I’ve got it wrong:

__sql__ = “select Customer.LName as Name from Customer where Customer.ID = Return.CustID”

This is in tables/Return/fields.ini

Thanks for considering this.


compudude86 — Wed Sep 20, 2006 10:44 am

ok, i tried the code and it brought down my dataface so i took it off. then i tried to switch to my mysql view, and when i did it was doing the thing of only showing the single items, so i made a column in my view to carry over the key, except it doesnt show as a key. does anyone know how id add a primary key to a view?


Aoirthoir — Wed Sep 20, 2006 11:18 am

Ah not sure Joe. I will see if it works. I’ve desired a dataface interface to MySQL views for a while. I added it to the issue tracker. Don’t know if it will be on the schedule anytime soon..but the primary key thing might solve it…


shannah — Wed Sep 20, 2006 11:43 am

ok, i tried the code and it brought down my dataface so i took it off. then i tried to switch to my mysql view, and when i did it was doing the thing of only showing the single items, so i made a column in my view to carry over the key, except it doesnt show as a key. does anyone know how id add a primary key to a view?

OK.. if it brought down dataface that means there is just a problem with the SQL query. Try running the query directly in mysql or phpmyadmin and modify it until it works. My hunch is that it is complaining about using CONCAT() with a non-string value.. might have to do some conversions. What is the SQL query you used to define your view in MySQL. You can probably just use this same query in the __sql__ line of your fields.ini file.

As far as making Dataface work with Views, it may be a simple mod, but I am currently running only MySQL 4.1.x on my systems - I’ll have to set up mysql 5 to begin developing for views … … So it may take some time.

Best regards

Steve


shannah — Wed Sep 20, 2006 9:52 am

Use the mysql FORMAT function to display the number to the correct decimal places, and use the CONCAT function to prepend a dollar sign.

e.g.
__sql__ = “select *, CONCAT(‘$’,FORMAT((SRP-NETBTL)/SRP),2) as GPM from tablename”

Or some variation on that… Check the mysql string functions manual page for more info about FORMAT and other functions that would be useful in this regard.

Hope this helps.

-Steve


Aoirthoir — Wed Sep 20, 2006 10:43 am

Playing around with this, it seems, this is only for calculated totals? It cannot be used to just include a field from another table into your table?

For instance I have two tables. Customer. Return. Customer has an ID which is contained within Returns as CustID. In the Returns list and view screens, would I be able to display the Customer name by setting up a Customer.ID = Return.CustID ?

This is what I tried from the code posted above..but clearly I’ve got it wrong:

__sql__ = “select Customer.LName as Name from Customer where Customer.ID = Return.CustID”

This is in tables/Return/fields.ini

Thanks for considering this.


compudude86 — Wed Sep 20, 2006 10:44 am

ok, i tried the code and it brought down my dataface so i took it off. then i tried to switch to my mysql view, and when i did it was doing the thing of only showing the single items, so i made a column in my view to carry over the key, except it doesnt show as a key. does anyone know how id add a primary key to a view?


Aoirthoir — Wed Sep 20, 2006 11:18 am

Ah not sure Joe. I will see if it works. I’ve desired a dataface interface to MySQL views for a while. I added it to the issue tracker. Don’t know if it will be on the schedule anytime soon..but the primary key thing might solve it…


shannah — Wed Sep 20, 2006 11:43 am

ok, i tried the code and it brought down my dataface so i took it off. then i tried to switch to my mysql view, and when i did it was doing the thing of only showing the single items, so i made a column in my view to carry over the key, except it doesnt show as a key. does anyone know how id add a primary key to a view?

OK.. if it brought down dataface that means there is just a problem with the SQL query. Try running the query directly in mysql or phpmyadmin and modify it until it works. My hunch is that it is complaining about using CONCAT() with a non-string value.. might have to do some conversions. What is the SQL query you used to define your view in MySQL. You can probably just use this same query in the __sql__ line of your fields.ini file.

As far as making Dataface work with Views, it may be a simple mod, but I am currently running only MySQL 4.1.x on my systems - I’ll have to set up mysql 5 to begin developing for views … … So it may take some time.

Best regards

Steve


compudude86 — Thu Sep 21, 2006 8:59 am

ok, i tried using my query too, doesnt work. how much of a modification is needed to display views? all i can see is it is just getting past the primary key issue, it displays everything else just fine, except for it only showing a line at a time because of the key


shannah — Thu Sep 21, 2006 9:12 am

In Dataface primary keys are extremely important because I need a way to uniquely specify a record using GET parameters. I suppose that the primary key could be specified in the fields.ini file to handle the case where it can’t be retrieved from the database.

In fact, this would probably work in the current version of dataface. Give it a try.

In the fields.ini file for the view that you are trying to use add the following to any field that is part of the primary key:

Key = PRI

for example, suppose that the ID field should be treated as a primary key. Then your fields.ini file should contain:

[ID]
Key = PRI

Give it a shot and let me know how it goes.

-Steve


compudude86 — Thu Sep 21, 2006 9:30 am

hmmm, doesnt seem to work, in my fields.ini, i add KEY = PRI under the [ID] tag, right? that doesnt work though


shannah — Thu Sep 21, 2006 10:14 am

Not KEY = PRI

Key = PRI

Case matters unfortunately.

-Steve


shannah — Thu Sep 21, 2006 10:18 am

The other thing is that the [ID] tag was only an example assuming that the field that you wish to use as a primary key is named ‘ID’. If you are using a field named ‘Name’ as the primary key, then it would appear under the [Name] section.

If you are using a multiple field primary key, then you would add ‘Key=PRI’ under each field section in the primary key.

If you still can’t get it working, perhaps try posting relavent table and view definitions, and your fields.ini file and I can give more specific instructions for your situation.

Best regards

Steve


shannah — Thu Sep 21, 2006 10:21 am

I was curious so I just had to test this out on my MySQL 5 box. It works.


compudude86 — Mon Sep 25, 2006 8:07 am

ok, yes, my field is named ‘ID’. i tried the key=PRI under my fields.ini, and it still doesnt work for some odd reason once i get onto my linuix machine ill give you my fields.ini


compudude86 — Mon Sep 25, 2006 8:16 am

ok, it isnt working. its only one field that is the primary key, and its named ID. here is my fields.ini:

[ID]
Key = PRI
widget:type = hidden
visibility:list = hidden

maybe this helps


shannah — Mon Sep 25, 2006 10:22 am

Some answers to the following will help me to know where your app is going wrong:

  1. What is the name of the view?
  2. What is the vew definition? (i.e. the SQL query)
  3. What is the path (relative to your application root) to your fields.ini file for the view.
  4. If the name of your view is ‘myview’, run the following query in mysql and provide the output:
    show columns from myview

I should be able to detect the problem given the results of the above questions.

-Steve


compudude86 — Mon Oct 09, 2006 11:07 am

ok, the name of the view is simply “view”, im unsure about the query at this time, the directories go
|— <—dataface folder
|— <—application
|———fields.ini


shannah — Thu Sep 21, 2006 10:21 am

I was curious so I just had to test this out on my MySQL 5 box. It works.


compudude86 — Mon Sep 25, 2006 8:07 am

ok, yes, my field is named ‘ID’. i tried the key=PRI under my fields.ini, and it still doesnt work for some odd reason once i get onto my linuix machine ill give you my fields.ini


compudude86 — Mon Sep 25, 2006 8:16 am

ok, it isnt working. its only one field that is the primary key, and its named ID. here is my fields.ini:

[ID]
Key = PRI
widget:type = hidden
visibility:list = hidden

maybe this helps


shannah — Mon Sep 25, 2006 10:22 am

Some answers to the following will help me to know where your app is going wrong:

  1. What is the name of the view?
  2. What is the vew definition? (i.e. the SQL query)
  3. What is the path (relative to your application root) to your fields.ini file for the view.
  4. If the name of your view is ‘myview’, run the following query in mysql and provide the output:
    show columns from myview

I should be able to detect the problem given the results of the above questions.

-Steve


compudude86 — Mon Oct 09, 2006 11:07 am

ok, the name of the view is simply “view”, im unsure about the query at this time, the directories go
|— <—dataface folder
|— <—application
|———fields.ini


shannah — Tue Oct 10, 2006 12:16 pm

Perhaps give 0.6.9 (the latest) a try… Joseph (Aoirthoir) has played around with views a little bit with this version and they seem to work for most things…

-Steve


compudude86 — Mon Oct 16, 2006 8:20 am

ok, i installed 0.6.9 and still no luck.


compudude86 — Mon Oct 16, 2006 8:58 am

nevermind, i figured out i didnt have a fields.ini for the view, named “view”, only for the table called “products”, so i guess i was experiencing an ID-10t error lol. all fixed now!! thank you very much


Aoirthoir — Mon Oct 16, 2006 1:24 pm

Joe, I solve this by doing a soft link to my fields.ini which I store in the main directory of my app. This way I have one single fields.ini file.


compudude86 — Tue Oct 17, 2006 9:14 am

ok thanks, i didnt think about that. now, i dont want to start threadjacking, but i figured this was an appropriate question to “help with design”, ive read over the docs on templates, but im lost. i want to change the color scheme from blue grey and green to a red, grey, and white. ive looked through the templates, but i cannot figure out how to change any of this…help?


shannah — Tue Oct 17, 2006 9:38 am

This change would be made using CSS. All of this is defined in the plone.css file.
You can override these styles by adding your own style sheet in the custom_stylesheets slot as follows:

  1. Create a stylesheet for your application. You can call it anything, but let’s call it styles.css and place it in the top level of your application’s directory.

  2. Override the custom_stylesheets slot of the MainTemplate by defining the block__custom_stylesheets() method in your application’s delegate class as follows:

Code: Select all
function block__custom_stylesheets(){      $styles_path = DATAFACE_SITE_URL;      if ( $styles_path{strlen($styles_path)-1} != '/' ) $styles_path .= '/';          // If there was no trailing slash to the styles path, we add one.      $styles_path .= 'styles.css';      echo << END;      return true; }
  1. Finally, define the appropriate styles in your styles.css file.

Hope this helps a little.

Best regards

Steve


compudude86 — Tue Oct 17, 2006 9:49 am

yes, it helps, except i cannot find plone.css


compudude86 — Tue Oct 17, 2006 11:08 am

duh, found it. thank you very much


Aoirthoir — Tue Oct 17, 2006 5:05 pm

I do the same thing but right within the plone.css itself. Simply add the following code:

@import url(filename.css);

Do this for each of the CSS files you want to add. Then within the CSS file change whatever you want.

However, the method Mr. Steve directed above works if you want different styles for each of your apps. Since I am storing my Dataface in a central location and using soft links to point to that one DF install from each of my domains, then all of them would use the modifications in my method. In Mr. Steve? method, each app could have its own additional CSS styles.


shannah — Tue Oct 17, 2006 9:38 am

This change would be made using CSS. All of this is defined in the plone.css file.
You can override these styles by adding your own style sheet in the custom_stylesheets slot as follows:

  1. Create a stylesheet for your application. You can call it anything, but let’s call it styles.css and place it in the top level of your application’s directory.

  2. Override the custom_stylesheets slot of the MainTemplate by defining the block__custom_stylesheets() method in your application’s delegate class as follows:

Code: Select all
function block__custom_stylesheets(){      $styles_path = DATAFACE_SITE_URL;      if ( $styles_path{strlen($styles_path)-1} != '/' ) $styles_path .= '/';          // If there was no trailing slash to the styles path, we add one.      $styles_path .= 'styles.css';      echo << END;      return true; }
  1. Finally, define the appropriate styles in your styles.css file.

Hope this helps a little.

Best regards

Steve


compudude86 — Tue Oct 17, 2006 9:49 am

yes, it helps, except i cannot find plone.css


compudude86 — Tue Oct 17, 2006 11:08 am

duh, found it. thank you very much


Aoirthoir — Tue Oct 17, 2006 5:05 pm

I do the same thing but right within the plone.css itself. Simply add the following code:

@import url(filename.css);

Do this for each of the CSS files you want to add. Then within the CSS file change whatever you want.

However, the method Mr. Steve directed above works if you want different styles for each of your apps. Since I am storing my Dataface in a central location and using soft links to point to that one DF install from each of my domains, then all of them would use the modifications in my method. In Mr. Steve? method, each app could have its own additional CSS styles.