Jump to content

FieldtypeFontIconPicker


ukyo

Recommended Posts

FieldtypeFontIconPicker

This field-type allow to you easily pick icons from input-field. This module using jQuery fontIconPicker as icon selector. You can see supported icon libraries below. If you need to use custom fonts you can check below example.

Supported Icon Libraries

Cahangelog


NOTE: Module store data without prefix, you need to add "prefix" when you want to show your icon on front-end, because some of front-end frameworks using font-awesome with different "prefix".


Module will search site/modules/**/configs/IconPicker.*.php and site/templates/IconPicker.*.php paths for FieldtypeFontIconPicker config files.

All config files need to return a PHP ARRAY like examples.


Example config file : create your own icon set.

File location is site/configs/IconPicker.example.php

<?php

namespace ProcessWire;

/**
 * IconPicker : Custom Icons
 */
return [
    "name" => "my-custom-icons",
    "title" => "My Custom Icon Set",
    "version" => "1.0.0",
    "styles" => array(
        wire("config")->urls->templates . "dist/css/my-custom-icons.css"
    ),
    "scripts" => array(
        wire("config")->urls->templates . "dist/js/my-custom-icons.js"
    ),
    "categorized" => true,
    "attributes" => array(),
    "icons" => array(
        "brand-icons" => array(
            "title" => "Brand Icons",
            "icons" => array(
                "google", "facebook", "twitter", "instagram"
            )
        ),
        "flag-icons" => array(
            "title" => "Flag Icons",
            "icons" => array(
                "tr", "gb", "us", "it", "de", "nl", "fr"
            )
        )
    )
];

Example config file : use existing and extend it.

File location is site/configs/IconPicker.altivebir.php

<?php

namespace ProcessWire;

/**
 * IconPicker : Existing & Extend
 */

$resource = include wire("config")->paths->siteModules . "FieldtypeFontIconPicker/configs/IconPicker.uikit.php";

$url = wire("config")->urls->templates . "dist";

$resource["scripts"] = array_merge($resource["scripts"], ["{$url}/js/Altivebir.Icon.min.js"]);

$resource["icons"]["flag-icons"] = [
    "title" => "Flag Icons",
    "icons" => array("tr", "en", "fr", "us", "it", "de")
];

$resource["icons"]["brand-icons"]["icons"] = array_merge($resource["icons"]["brand-icons"]["icons"], array(
    "altivebir"
));

return $resource;

After you add your custom config file, you will see your config file on library select box. Library Title (Location Folder Name).

Library Select

If your library categorized and if you have categorized icons set like uikit and fontawesome libraries, you will have category limitation options per icon field or leave it empty for allow all categories (default).

Library Select


Example : output

if ($icon = $page->get("iconField")) {
    echo "<i class='prefix-{$icon}' />";
}

MarkupFontIconPicker Usage

// MarkupFontIconPicker::render(YourIconField=string, Options=array)
echo MarkupFontIconPicker::render($page->YourIconField, [
        'prefix' => 'uk-icon-', // Icon class prefix, if you have different prefix, default is : "fa fa-"
        'tag' => 'span', // Icon tag default is : "i"
        'class' => 'fa-lg', // If you have extra cutom classes, for example : icons sizes, Array or Sting value
        'style' => 'your custom styles if you have' // Array or String Value
    ]);

Theme support

Library Select

Search support

Library Select

Category support

Library Select

 

  • Like 13
Link to comment
Share on other sites

Great work - just playing with it now and it's really slick - thanks for the contribution!

One thing I noticed - not a big deal, but when you search by text, with "From all categories" selected, it duplicates the matching icons.

Also, out of interest, did you see this: http://processwire.com/blog/posts/processwire-core-updates-2.5.15/#new-icon-selection-module-in-the-core

It's an Inputfield, but not a Fieldtype, so it can't be used in templates as is, but I wonder how these two modules could be consolidated, or maybe they should remain completely separate - just thinking out loud - I have no idea whether Ryan is planning a matching fieldtype for his module.

Link to comment
Share on other sites

Great work - just playing with it now and it's really slick - thanks for the contribution!

One thing I noticed - not a big deal, but when you search by text, with "From all categories" selected, it duplicates the matching icons.

Also, out of interest, did you see this: http://processwire.com/blog/posts/processwire-core-updates-2.5.15/#new-icon-selection-module-in-the-core

It's an Inputfield, but not a Fieldtype, so it can't be used in templates as is, but I wonder how these two modules could be consolidated, or maybe they should remain completely separate - just thinking out loud - I have no idea whether Ryan is planning a matching fieldtype for his module.

Thanks for your feedback !

I think, duplicate problem is not actually a problem. Why ? : I took all icons from font-awesome website by categorized and 1 icon may in more than 1 category.

I see @Ryan module, i am trying to use always dev version of processwire and i can follow updates, new things better, but you can't use it on page as a field. @Ryan solution is good for templates and field icons select.

If you think from customer side : Simple example, think you have links page for social network website. You need an icon for each link page and you can easily select icon from select list. you don't need to search icon class inside font-awesome website or inside a icon class guide. Just select it from list. Also its possible to limit icons from input setting tab by category.

Link to comment
Share on other sites

Yes, I submit it. Waiting for approve.

Also if you can, can you correct the url of my dev profile

False  -> /alt-ve-bir-bilisim-teknolojileri/ (Loosing small "ı")  ???

True   -> /alti-ve-bir-bilisim-teknolojileri/ (Turkish characters ). ı -> i

note: I added logo also again. When you make post on dev form profile, if validation is not ok fields coming as blank field.

O0

Link to comment
Share on other sites

Having a small z-index problem

attachicon.gifScreen Shot 2015-02-08 at 5.19.31 PM.png

Thanks for your feedback!

Z-index problem causing from content section ("<div id='content' class='content'>").

Icon selector z-index value is "10000" and not effecting outside of "content" section, if you add z-index value = 2, to "<div id='content' class='content'>" element its looking ok.

Need a hack for ("<div id='content' class='content'>") section by jquery or core team can add a z-index value for this section. If core team can do it, i don't need a hack for z-index. If they can't i can add a little hack for this problem. Will wait for core team answer.

Link to comment
Share on other sites

But PW has the "<div id='content' class='content'>" with z-index: 0, jquery is fine. I don't see a reason why PW needs a z-index: 0 there at all as it will result all absolute containers inside #content underlap #footer cause #footer has no z-index.

Link to comment
Share on other sites

Z-index values looking ok, but how copyright informations coming up?

When i check page render result with firebug, footer section looking ok, .container element inside footer section coming up of absolute element.

My solution is hack #content element or #footer .container element by little jquery code. Add a z-index value when document ready to #content "z-index: 2;" or #footer .container "z-index: -1;". Problem solve with this method.


You can change InputfieldFontIconPicker.module line 94 with this code, I will update repo also :
 
$output .= "\n<script>
		\n\tjQuery(document).ready(function($) {
		\n\t\t$('#{$options['id']}').fontIconPicker({
		\n\t\t\tsource: {$options['icons']},
		\n\t\t\t{$settings}
		\n\t\t});
		\n\t\tif($('#content').length) {
		\n\t\t\t$('#content').css('z-index', 2);
		\n\t\t}
		\n\t});
		\n</script>";
Link to comment
Share on other sites

Ugly things! :)

PW should remove the z-index:0 from #content. No need to add it and if there's a reason it can be solved differently by adding z-index: 0 to footer too, but then why? PW has that wrong not your module or the plugins so PW needs to sort that out cause it's a ”bug".

It's like "adding !important to all elements that need overriding specification problems in you CSS".


Z-index values looking ok, but how copyright informations coming up?

#header (stacking order 1)

#content (stacking order 1)

#footer (stacking order 1)

now a "z-index: 0" to #content will make it

#header (stacking order 1)

#content (stacking order 0)

#footer (stacking order 1)

So content is "under" footer now.

Link to comment
Share on other sites

ok, this issue comes from the array notation!

$array = array($foo, $bar); // is ok

$array = [$foo, $bar]; // only php version 5.4+

had this issue today with a different module so i thought it was not specific to this module and did some research...

Link to comment
Share on other sites

ok, this issue comes from the array notation!

$array = array($foo, $bar); // is ok

$array = [$foo, $bar]; // only php version 5.4+

had this issue today with a different module so i thought it was not specific to this module and did some research...

For compatibility, i will change [$foo, $bar] to array($foo, $bar).

- Edit : Done. You can update module.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

I don't know what I am doing wrong but I can't get this module to work.

I tried it on a fresh install of processwire 2.5.3

I just get as the image shows below. No way to pick an icon.

attachicon.gifCapture.JPG

I created Module with last dev version. Let me check for last stable version and i can see what is problem for oldest versions.

Edit: Problem solved can you confirm after update to v0.0.5

  • Like 2
Link to comment
Share on other sites

  • 2 months later...
  • 3 weeks later...

On Install i get :

Parse error: syntax error, unexpected '[' in /somepath/site/modules/FieldtypeFontIconPicker/InputfieldFontIconPicker.module on line 22

I guess this is because that server uses php 5.4.   that does not support the new [] Syntax.

The funnie thing about that is that it should support it !

Link to comment
Share on other sites

Nice module! Love the good work ( Ellerine saglik ukyo ;-) )

I would like to know if it's possible to include the icon package of foundation http://zurb.com/playground/foundation-icon-fonts-3

regards,

Gerald

Yes its possible, you can configure module as your needs

On Install i get :

Parse error: syntax error, unexpected '[' in /somepath/site/modules/FieldtypeFontIconPicker/InputfieldFontIconPicker.module on line 22

I guess this is because that server uses php 5.4.   that does not support the new [] Syntax.

The funnie thing about that is that it should support it !

- Corredted with last commit, you can download 0.0.6 version

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Hi! Awesome Module (pun intended) ;)

This would turn out very usefull for my next project, However I get some strange behaviour when leaving an edit page without changing anything on the icon. It gives me a confirm box saying there is unsaved content (see attachment). Does anybody have the same behaviour or knows what I do wrong here? 

Thanks for any suggestion. 

Sascha

post-3736-0-21412600-1444594672_thumb.pn

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

Great extension! Very useful for a project of mine, thank you!

I have the same problem as saschapi. I save my page. Next I want to leave, I get a browser message (firefox) telling me that I have unsaved data.

Google translation from German:

"This page asks you to confirm that you want to leave the page - data you have entered will not be saved under certain circumstances."

Link to comment
Share on other sites

Hi ukyo, did you find anything? ;)

 

 

Great extension! Very useful for a project of mine, thank you!

 

I have the same problem as saschapi. I save my page. Next I want to leave, I get a browser message (firefox) telling me that I have unsaved data.

 

Google translation from German:

"This page asks you to confirm that you want to leave the page - data you have entered will not be saved under certain circumstances."

 

 

Hi! Awesome Module (pun intended) ;)

 

This would turn out very usefull for my next project, However I get some strange behaviour when leaving an edit page without changing anything on the icon. It gives me a confirm box saying there is unsaved content (see attachment). Does anybody have the same behaviour or knows what I do wrong here? 

 

Thanks for any suggestion. 

 

Sascha

Sorry i am to busy with work and i know the issue. I think this issue appear, because fonticonpicker js library changing the processwire field attributes. I will do one more hidden field for fonticonpicker js attributes and after done i will update processwire field. Started to work on it.

Thanks for interest !

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...