Renaming 'add' and 'select' links in relations
From Achievo/ATK Wiki
|
ATK Howto: Renaming 'add' and 'select' links in relations
|
ATK 5.7 has many great unexplored features which allow for greater flexibility to customize the application.
In this segment I'm going to explore the ways you can change the links label for "Add" in one-to-many relations and the "Select" on many-to-one relations.
Comment: This is a good way of solving a translation problem when the link text is translated to a language with accented characters or umlauts. The relation attributes use the PHP function 'strtolower' after translating the link text with atktext, which could result in an illegal character in the translated link text. By explicitly setting the link text as described below you will avoid this problem.
Basic Language file setup:
Make sure your language file is working properly. The basics for this is:- 1a. Create a folder called "languages" under your module
- 1b. create a file called "your_language_code.lng". For example if your language is English, then your file name should be "en.lng" (Search the ATK wiki for language setup, if you need detail instructions on how to setup languages in ATK)
Changing “Add” label of one-to-many Relation:
To change the "Add" label your one-to-many node use enter the following in your language file:
"link_o2mAttributeName_add"=>"Your new label"
For example of you had two nodes, one being your "Order" node and the other your "Order detail" node and you wanted to change the default message on your "Order" node from "Order detail add" to "Add New Line Item" then:
Assumming you have the following in your "Order" node
$this->add(new atkOneToManyRelation("order_detail","webstore.wbiz_order_detail","order_id", AF_HIDE_LIST | AF_CASCADE_DELETE|AF_NOLABEL),NULL,750);
Then you may place the following on your "en.lng" (or corresponding) language file;
"link_order_detail_add"=>"Add New Line Item",
Now, let's say you wanted to impress your users with a nice icon intead of some boring text. In my case I have an icon (order_add_48x48.png) under a directory called "/modules/gktools/images/"
To display this icon in place of the text, I simply add the following to my "en.lng" language file:
"link_order_detail_add"=>"<img src='./modules/gktools/images/order_add_48x48.png' alt='Add New Line Item' border=0 align=middle>",
You are done. You can now test your new label, by refreshing your node screen.
Changing “Select” Label of many-to-one relation:
By default when add the “AF_LARGE” flag to a many-to-one relation, ATK 5.7 will add three options next to the attribute in edit mode. These three options are: • Select – which allows you to go select an item • Edit – allows you to edit the selected item • New – allows you to create a new item
To change the default “Select” label use the following syntax in your language file:
"link_select_m2oNodeName"=>"new label”
Where “m2oNodeName” is the actual name of your many-to-one relation.
Let’s say we have a node called “order_detail”, which in terms has a many-to-one relation called “product” and we wanted to change the default “select” label from “select product” to “Browse Products”.
Assuming we have the following in your “order_detail” node:
$this->add(new atkManyToOneRelation("product_id","webstore. product", AF_LARGE),NULL,400);
Then all we need to do is add the following to our “en.lng” (or corresponding) language file:
"link_select_product"=>" Browse Products”
Now let’s say we wanted to make things a little more appealing by showing a nice icon instead of boring text. Assuming our icon is named “find_next_16x16.png” and is located on a directory with ATK called “/modules/gktools/images/” then we add the following to our language file:
"link_select_product"=>"<img src='./modules/gktools/images/find_next_16x16.png' alt='Search Product' border=0 align=middle>",
You are done. Now go customize your ATK applications
Until next time,