Overwrite or custom function?

I'd like to use a custom image search button for my search form, rather than the CSS styled one. I know where to change the code in `template-functions.php` - but is there a better practice to overwrite a function on a per template basis? I have a `custom-function.php` file, but if I simply re-create the function I need to change I get an error (`function already defined`).

Comments

  • acrylian Administrator, Developer
    Overwriting a functions could cause problems with updates, especially within such an integral file. A custom functions would be the better way. You can just copy the code and rename the function then you won't get any conflict.

    You also could take a look at the new plugin feature in the nightlies, it's basically the same as a custom function, but much more comfortable.
  • PHP does not let you override a function definition. If you make changes to the zenphoto core you are likely to have to research and reapply hte changes at each zenphoto upgrade. So it is better to create a new function with a new name for your use.

    If you can think of a way to make your changes compatible with normal search buttons, please suggest changes that to the template functions. Perhaps they could be adopted into the standard release.
  • That's great advice, thank you.

    Perhaps in a future version, simply add a '$src' parameter to the function. If it's not null, then the search button code is replaced with a `type` of "image" and the `src` being the file passed in.

    `echo "n";`

    instead of

    `echo "n";`

    In case anyone is interested, here my the zenPhoto implementation : http://www.breckenridgephotoshop.com/gallery/
  • Consider it done.
Sign In or Register to comment.