problem calling `filterAccentedCharacters` function in ZP 1.4

hi,

i have a filter that i wrote for zenphoto 1.2.9. it used to make good use of the `filterAccentedCharacters` function that was in the filter-zenphot_seo.php file. it is now located in the zenphoto_seo.php file. nothing has really changed except that few hebrew characters have been added to the specialchars array. anyway the call to the function in my filter is not working anymore. if i comment the call, everything is fine. i even tried to comment everything in the function but still the call is not going through. i am a bit puzzled. any idea on what's going on ?

of course i have enabled the zenphoto_seo plugin to be able to mak a call to the function.

thanks for your help,
frank

Comments

  • So, some more detail, maybe. What do you mean by "not working"? Is it throwing errors?

    BTW, you are not really using the function correctly (although it should work so long as the plugin is enable.)

    What you should be using is the seoFrindly() function. That function uses whatever is configured for the "seoFriendly" filter, including a default translation should none be configured.
  • what i have in my filter is something like this
    `$imgname = filterAccentedCharacters($imgname);`
    and the execution of the code stops on this instruction. there is no error, the execution just stops.

    if i edit the `filterAccentedCharacters` function in the zenphoto_seo.php file and add an echo instruction such as `echo 'here we go';` right at the beginning of the function, nothing prints. it looks like it does not even enter the `filterAccentedCharacters` function.

    hopefully, this helps a bit. with the version 1.2.9, activating a plugin or a filter was enough for all its functions to be known everywhere, i am now wondering if since then one has to add a specific instruction so that functions of one plugin can be used in another one ?
  • acrylian Administrator, Developer
    Maybe you should really post either more details or the complete plugin. Why do you need this filter actually? The plugin is meant to hook into the upload/creation process on the backend for all Zenphoto items already.
  • Well, if it is not entering the function it is not a problem of the function. Surly if execution stops there will be some kind of script error generated. You will need to find that.

    If not, then be sure you are really getting to the line in your plugin.

    But better anyway is that you use the standard seoFriendly() function as described above.
  • i have tried to use the `seoFriendly` function as recommended but not very successfully.

    right now what i need is a seo friendly version of the image title which can contain accented characters (french, spanish...), double dashes or spaces.

    basically if the image title is "René Hood" i want to turn it into "rene-hood". looking at the `filterAccentedCharacters` function, it seems to me that's what it does. i understand that it is anyhow a filter applied to the `seoFriendly` function and therefore i should only call `seoFriendly`.

    using the zenpage theme, i made a simple test. i added this code right after `` tag:
    `
    <?php
    $test='René Hood';
    $seotest=seoFriendly($test);
    echo 'seo-ed test: ' . $seotest;
    ?>
    `
    the result is "RenHood" and not "rene-hood". am i missing something ?

    inside the `seoFriendly` function in the functions.php file i have looked at the `has_filter` test and it looks like the `filterAccentedCharacters` filter is not applied (looks like we only go through the else - basic cleanup - instruction).

    note the lower case option in the zenphoto_seo plugin is checked.
  • the zenphoto_seo plugin is a "back-end" plugin. That is, it is not loaded for theme pages so you are getting the default seoFriendly() processing which just strips out the suspect characters. You will have to cause your them to do a `require_once()` on the plugin to get it to load on the front end.

    But just for curiosity, why are you stripping the diacritical marks from the title? The filter is back-end only because it is normally used only for converting file/folder names so that both the URL looks better and filesystems which do not support those characters will work.
  • thanks for the tip. i missed that `require_once` instruction.

    now to answer your curiosity... basically i have different albums. in every album, the photos have a generic filename and a number that differentiate them (e.g. burma-1.jpg, burma-2.jpg and so on).

    i have read that for image search, the filename is important and it is better to have some kind of explicit name such as jumping-cat.jpg rather than burma-34.jpg. well that's is what i read. as google is very opaque, i do not know to what extent this is true.

    anyway i had in mind to change the name of my pictures and have it reflect the title of the pic. i could have simply renamed all pics once for all but i have so much more on my harddrive that are waiting to be uploaded that i thought it would maybe be better to keep things how they are and just write a filter that does that.

    i did with ZP 1.2.9 and it works ok. you can check that on my burmese gallery for instance.

    i want to port this feature to the latest ZP1.4 version and that's where i am... working on it.

    doing things this way is the solution i have chosen which might not be the best. maybe there is already a function that i haven't seen which does that. if you have any feedback i'll be glad to hear it even if it is to tell me that this filter thing sounds stupid.
  • Ok, makes sense now that I understand.
  • with ZP1.2.9, i used to be able to do jsut by applying a filter on load_request. right now, with ZP1.4, i have difficulties to do that.

    so basically i went back to the basics and here is my "stripped" plugin

    `
    <?php
    $plugin_is_filter = 5|CLASS_PLUGIN;
    $plugin_description = gettext("Plugin/Filter description");
    $plugin_author = "frankm";
    $plugin_version = "1.4";

    zp_register_filter('load_request', 'filterImageReq');

    function filterImageReq($allow) {

    echo 'inside the filter <br />';

    return $allow;
    }
    ?>
    `
    looks to me it is very similar to the seo_locale filter that is applied to the same load_request. anyway, i never get the message "inside the filter" printed on the very top of my page. i'm stuck as i can't get the filter to be simpler.
  • Prbably you were caught by a little trap. If you change the `$plugin_is_filter` setting you need to do an Apply on the plugins tab. That value is stored as the "enabled" option and used when Zenphoto decides when to load the plugin. So probably the test was being made on the old value.

    We manage to hide that most times as Setup will also insure the value in the option is correct. But of course if you are developing a plugin this is something you would need to know.
  • BY the way, you might want to look at the new utility in the development stream named SEO cleanup.

    It is doing almost what you describe. But instead of using the title for the name it is just using seoFriendly() on the filename. If you are actually changing the filename of the image you should remember that there are database entries that have to get handled as well. This utility does take care of that.
Sign In or Register to comment.