Page 1 of 1

Rename labels

Posted: 2021-01-20 07:11
by SkayyHH
Hi,

maybe someone has a code how to rename field labels easily in the hooks?

Many thanks! Kai

Re: Rename labels

Posted: 2021-01-20 18:23
by pfrumkin
Hello Kai,

I assume you realize that the AppGini interface allows you to specify the UI label when defining each column of a table.

I have some logic that requires to potentially change the label dynamically based on input. I have done this using the AppHelper library in a tablename-dv.js script, but I suspect it could be in the tablename_dv hook in a script block. I have

Code: Select all

		var fieldname = "l_name"; 
		new AppGiniField(fieldname).label("Last Name");
Hope that helps.

~Paul

Re: Rename labels

Posted: 2021-01-20 18:37
by landinialejandro
hi! other way is in your tablename.php in hooks folder, inside the init function write this:

Code: Select all

$options->ColCaption = ['fname1', faname2', 'NEWfname3', 'fname4' ];
if you have a tv with 4 cols.

Re: Rename labels

Posted: 2021-01-21 08:49
by SkayyHH
Thank you very much for the help.

Unfortunately, I cannot use the AppHelper library with my customers.

I have tried the tip from Alejandro :-)

But unfortunately I get only a blank page.

The code is:

Code: Select all

	function Documents_de_init(&$options, $memberInfo, &$args){$_SESSION ['tablenam'] = $options->TableName;
$_SESSION ['tableID'] = $options->PrimaryKey;$tableID = $_SESSION ['tableID'];


             $options->ColCaption = ['fname1', faname2', 'NEWfname3', 'fname4', 'fname5', 'fname6'];

		return TRUE;

	}
I have 6 cols.

Thanks again and many greetings, Kai

Re: Rename labels

Posted: 2021-01-21 20:42
by SkayyHH
I have tested a bit more. it works for the table view but not for the detail view, print view etc. What else can I do?

thanks a lot, Kai

Re: Rename labels

Posted: 2021-01-22 21:10
by pfrumkin
I googled and found that it looks to be pretty easy in JQuery, place in the tablename_dv hook in a script block

Code: Select all

$j("label[for='yourField]").text('NewLabel');

Re: Rename labels

Posted: 2021-01-22 22:31
by landinialejandro
pfrumkin wrote:
2021-01-22 21:10
I googled and found that it looks to be pretty easy in JQuery, place in the tablename_dv hook in a script block

Code: Select all

$j("label[for='yourField]").text('NewLabel');
i think this is the best way.

the camption in DV are fix in template html, inside the templates folder. you can take a look there.

this is other way, rename inside this template tablename_tamplateDV.html.

but... way you don't change this caption in your project in appgini?

Re: Rename labels

Posted: 2021-01-23 08:18
by SkayyHH
Hi, so many thanks for your help :-)

Code: Select all

$j("label[for='yourField]").text('NewLabel');
This is what works for the detail view. Very good.
I put it in the .js file in /hooks.

However, this is still not the optimal solution. Something about the background. I have a few custom fields for the customer. he should be able to name the fields himself. Therefore I can't just change that in appgini.

I would prefer a file in which the user of the app can name the custom fields themself and these field names are then displayed throughout the app. Also in admin , search, filters .... basically like a language file.

custom1 = Color
custom1 = Height
custom1 = xyz
custom1 = ...

Many greetings, Kai

Re: Rename labels

Posted: 2021-01-23 14:56
by landinialejandro
that my friend is not so easy to solve. If you need a self-configurable platform depending on your client, you will have to look for another type of solution.
for example it occurs to me that you edit the dv template, and in each fixed tag put for example <%% mylabelname %%>. then in the hook of the table in the init function, you already have the html processed. There you should make a function that replaces this <%% mylabelname %%> with your own customization. You can also do it with the rest of the things you want to configure.

Re: Rename labels

Posted: 2021-01-23 15:14
by pfrumkin
Yes, agree with Alejandro, that is a much bigger problem. It's not clear from the description of the problem - is this to allow individual users to change their UI on the fly, or is there a specific experience to configure by group of users, say company?

I have built a rudimentary system in which based on company, it is a different experience. I didn't get into specific .css files for instance though this could probably be extended to allow for specific styles per company (I did not need). I suppose you could add logic in your .js file(s) to check for company membership and do specific things. What I'm proposing is not dynamic, requires developer configuration. Making this dynamic is too big an ask, IMHO.

~Paul

Re: Rename labels

Posted: 2021-01-23 17:12
by pbottcher
Hi,

just as an idea. Put the code in the tablename_dv hooks and create the javascript according to the settings of the customer. You could have a file per customer and load that, or have all stored in the database.

Re: Rename labels

Posted: 2021-01-24 11:33
by SkayyHH
Hi,

the app is installed on the customer's server. the users do not have to make any changes to the labels. the labels should be customized by the admin or system-admin during installation according to the customer's needs.

I have to think again. I am not a programmer either and can hardly do this myself. The best would be of course a table in which the field names of all labels are located and then we can define alternative field name labels there. best still multiple e.g. to adapt the labels to different languages. i find that is missing in appgini. i have a language file but must define the field names in appgini. so you can not build a multi-language app.

best would be a code for the tablename.php in the hooks with which someone can swap the field names.

Re: Rename labels

Posted: 2021-01-24 13:17
by pbottcher
True,
but you need to keep in mind what AppGini is currently. There is no "out-of-the-box" multilingual switching.

Re: Rename labels

Posted: 2021-01-24 15:35
by SkayyHH
I know :-)

I'm thinking about creating a database structure for each language and adding the corresponding languages via the navigation.

i.E.

table1_en
table2_en
table3_en
table1_en
table2_en
table3_en


But in the admin I have to see again everywhere all tables.

Thus with appgini for each language an app ;-)