Rename labels

Discussions related to customizing hooks. Hooks are documented at http://bigprof.com/appgini/help/advanced-topics/hooks/
Post Reply
SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Rename labels

Post by SkayyHH » 2021-01-20 07:11

Hi,

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

Many thanks! Kai

pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Rename labels

Post by pfrumkin » 2021-01-20 18:23

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

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Rename labels

Post by landinialejandro » 2021-01-20 18:37

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.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Rename labels

Post by SkayyHH » 2021-01-21 08:49

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

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Rename labels

Post by SkayyHH » 2021-01-21 20:42

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

pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Rename labels

Post by pfrumkin » 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');

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Rename labels

Post by landinialejandro » 2021-01-22 22:31

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?
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Rename labels

Post by SkayyHH » 2021-01-23 08:18

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

User avatar
landinialejandro
AppGini Super Hero
AppGini Super Hero
Posts: 126
Joined: 2016-03-06 00:59
Location: Argentina
Contact:

Re: Rename labels

Post by landinialejandro » 2021-01-23 14:56

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.
Alejandro.
AppGini 5.98 - Linux OpenSuse Tumblewweed.

Some of my posts that may interest you:
:arrow: Landini Admin Template: Template for Appgini like AdminLTE
:arrow: Profile image plugin: add and changue image user profile
:arrow: Field editor in table view: Configurable fast edit fields in TV
:idea: my personal page

pfrumkin
Veteran Member
Posts: 157
Joined: 2020-02-18 17:58
Location: Albuquerque, New Mexico USA

Re: Rename labels

Post by pfrumkin » 2021-01-23 15:14

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

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Rename labels

Post by pbottcher » 2021-01-23 17:12

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.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Rename labels

Post by SkayyHH » 2021-01-24 11:33

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.

pbottcher
AppGini Super Hero
AppGini Super Hero
Posts: 1635
Joined: 2018-04-01 10:12

Re: Rename labels

Post by pbottcher » 2021-01-24 13:17

True,
but you need to keep in mind what AppGini is currently. There is no "out-of-the-box" multilingual switching.
Any help offered comes with the best of intentions. Use it at your own risk. In any case, please make a backup of your existing environment before applying any changes.

SkayyHH
Veteran Member
Posts: 425
Joined: 2015-04-27 21:18

Re: Rename labels

Post by SkayyHH » 2021-01-24 15:35

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 ;-)

Post Reply