Page 1 of 1

Custom Function override

Posted: 13 Oct 2008, 22:03
by artgroup
Hi all,
I modified the html.api file to highlight the current selected project into the Project Menu Bar and everything was working as expected. Than I moved my modificationt to the custom_functions_inc.php file so that I do not touch the original code, but now it's not working anymore the patch.

Code: Select all

<?php
	function custom_function_override_print_project_menu_bar() {
		$t_project_ids = current_user_get_accessible_projects();
    $t_current_project = helper_get_current_project();
    
		PRINT '<table class="width100" cellspacing="0">';
		PRINT '<tr>';
			PRINT '<td class="menu">';
			if ($t_current_project == ALL_PROJECTS) {
        PRINT '<b><font color="#FF0000"><href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</style></a></b></font>';
      } 
      else {
      	PRINT '<small><a href="set_project.php?project_id=' . ALL_PROJECTS . '">' . lang_get( 'all_projects' ) . '</a></small>';
      }
      
			foreach ( $t_project_ids as $t_id ) {
        if ($t_current_project == $t_id) {
          PRINT ' | <b><font color="#FF0000"><href=\"set_project.php?project_id=$t_id\">' . string_display( project_get_field( $t_id, 'name' ) ) . '</a></b></font>';
        } 
        else {
          PRINT " | <small><a href=\"set_project.php?project_id=$t_id\">" . string_display( project_get_field( $t_id, 'name' ) ) . '</a></small>';
        }  
				custom_function_override_print_subproject_menu_bar( $t_id, $t_id . ';' );
			}

			PRINT '</td>';
		PRINT '</tr>';
		PRINT '</table>';
	}
?>
<?php
	function custom_function_override_print_subproject_menu_bar( $p_project_id, $p_parents = '' ) {
		$t_subprojects = current_user_get_accessible_subprojects( $p_project_id );
		$t_current_subproject = helper_get_current_project();
		
		$t_char = ':';
		foreach ( $t_subprojects as $t_subproject ) {
      if ($t_current_subproject == $t_subproject) {
        PRINT "$t_char <b><font color='#FF0000'><href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a></b></font>';
      } 
      else {
        PRINT "<small>$t_char <a href=\"set_project.php?project_id=$p_parents$t_subproject\">" . string_display( project_get_field( $t_subproject, 'name' ) ) . '</a></small>';
      }  
			print_subproject_menu_bar( $t_subproject, $p_parents . $t_subproject . ';' );
			$t_char = ',';
		}
	}
?>
what is wrong?

The code above removes the hyperlink to the current project, set bold as font and RED as text colour.

Re: Custom Function override

Posted: 14 Oct 2008, 06:27
by deboutv
Only functions in the file core/custom_function_api.php could be overridden. So you trying to make something impossible.

Re: Custom Function override

Posted: 29 Aug 2024, 09:14
by mpa
I'm having a similar question and want to override a core function, in my case file_normalize_attachment_path
Is there no option or trick to do this?

Re: Custom Function override

Posted: 31 Aug 2024, 13:24
by cas
Same answer as in 2008 is valid. So if there is no such function defined, you cannot override it. :mrgreen: