This topic is locked
[SOLVED]

 change fieldnames on the fly?

5/10/2011 7:34:41 AM
PHPRunner General questions
M
mickna author

I have headache and I am sure there is a way to do this.

I'll guess with an Before display Event. However, I have no idea what are the variables to change this.
I have a tableA displayed in List View.

I also have a tableB which holds different names for the field names (row00) from tableA and I like to change the output to this names.

So I should be able to extend the different names, if needed
tableA

layout (= INT)

field1 (= some records)

field2 (= some records)

field3 (= some records)

...
tableB

layout | 1 | 2 | 3

field1 | wowo1 | version3 | ade

field2 | wowo2 | version0 | zth

field3 | wowo3 | version7 | opo
If tableA.layout = 1 I would like to have the table names in list view from tableA

wowo1 | wowo2 | wowo3

(instead of field1 | field2 | field3)
if tableA.layout = 2

version3 | version0 | version7
Does this make sense and can someone point me to the right direction?

thanks,

mickna

Sergey Kornilov admin 5/10/2011

Have no idea what you trying to achieve.

M
mickna author 5/10/2011



Have no idea what you trying to achieve.


I thought I was clear <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=58222&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />
Example list page:



Row 0 shows "Collection Name | Name | Production year | ...."
I know, I can change the caption in Datasource tables, but this is static, isn't it?

I'd like to change it via another table, where I have different caption / labels, depending on a value.

If the table above (the image) has an ID = 0 I want to show (as an example) "Pets Name | Owner Name | Birth Date |...."

If the table above has an ID = 1 I want to show as lable / caption "Friends Name | Girlfriend | some Date | ....."
This should be driven from another table, where I am able to add, change the labels / captions.
Do you know, what I mean?
thank you,

mickna

P
procheck 5/10/2011

You might want to try creating all of the required columns in table or possibly a view and Hide & Show the columns as required.

M
mickna author 5/10/2011

Thank you.
Of course I have a table with the required labels (this has to be a external/second table).

However, I do not know how to pull this labels out of the second table and use them as caption/labels for the first table, which is actual shown.
With an event in View Page I can read out the labels:
$fields = mysql_list_fields("databaseName","TableName");

$columns = mysql_num_fields($fields);
for ($i=0; $i<$columns; $i++){

echo mysql_field_name($fields, $i). " - ";

}
But I want to assign a new Name for each label which is pulled out of another table like
//Pseudo Code

$oldFields = mysql_list_fields("databaseName","TableName");

$newFields = mysql_list_fields("databaseName","AnotherTable");

$columns = mysql_num_fields($oldFields);
for ($i=0; $i<$columns; $i++){

mysql_field_name($oldFields, $i) = mysql_field_name($newFields, $i)

}
mickna

Sergey Kornilov admin 5/10/2011

I suspect that prochecksports is talking about columns in HTML table rather than database columns.
Anyway, my suggestion is to use Code Snippets for this task.
Here is how typical column header looks in HTML mode (column label is Address):

<TH style="VERTICAL-ALIGN: baseline" class=headerlist align=middle>{BEGIN Address_fieldheader}<A

class=tablelinks {$Address_orderlinkattrs}>Address</A>

{END Address_fieldheader}</TH>


You can replace Address with code snippet and write your code that pulls label from another table and displays it.



<TH style="VERTICAL-ALIGN: baseline" class=headerlist align=middle>{BEGIN Address_fieldheader}<A

class=tablelinks {$Address_orderlinkattrs}>{$event Address_snippet}</A>

{END Address_fieldheader}</TH>

M
mickna author 5/10/2011

Thank you Sergey,
this works.
Take care,

mickna