Forums: How to change field labels via php before page display - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to change field labels via php before page display great new time saver - no change to html view

#1 User is offline   FunkDaddy 

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 166
  • Joined: 17-March 10

Posted 02 September 2016 - 08:30 PM

Say you want to change a field label on list page, side search panel, add, edit, view, etc (any page).

Add this to your After Application Initialized event:


function setFieldLabel($table, $field, $custom_label )
{
	global $field_labels;
	if(!array_key_exists($table,$field_labels))
		return "";
	@$field_labels[$table][mlang_getcurrentlang()][$field] =  $custom_label;
}



Now in whichever page you need to update label simply add to before display event:

setFieldLabel('db_table_name', 'db_field_name', 'My Cool New Label');



I had to come up with this because the $xt->assign('fieldname', 'new_value'); example in manuals simply do not work for $label vars shown inside out html templates (when viewing them in visual editor in html mode).

Hope this helps folks

Marcelo Ramagem
Marcelo Ramagem

- Don't second guess your customer, instead listen, iterate, and deliver!
0

#2 User is offline   emendoza 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 8
  • Joined: 08-December 12

Posted 11 February 2017 - 02:16 PM

Friend FunkDaddy, excellent tips!
I've had this need to change a field label.

My congratulations for this contribution!
I leave,
Sincerely;

Eduardo Mendoza
www.audixp.com/portal
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic