Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New Plugin - CustomFields
#1
Hi,

New plugin "CustomFields" for version 2, which as the name says allows you to add new fields to your pages.
At the moment it supports "textbox" and "dropdown" fields, more planned for the next release.

Until we have a repository for plugins, more information and download from here....

http://www.digimute.com/index.php?id=blo...e-2-plugin

Now updated to version 1.3

History
1.3 fixed bug introduced in latest svn
1.2 added dropdown functionality which was ommited from initial release.
1.1 changes hook before template so values are available to your theme
1.1 fixes getCustomField which did not return values
1.0 initial release



Mike....
My Github Repos: Github
Website: DigiMute
Reply
#2
Thanks Mike... this was easily the most requested feature for plugins... thanks for doing this
- Chris
Thanks for using GetSimple! - Download

Please do not email me directly for help regarding GetSimple. Please post all your questions/problems in the forum!
Reply
#3
Thanks Mike! Yes - I was pushing for a Plugins Forum Topic a while back Smile

Side note: I think I wish plugins sat as it's own top level directory rather than in the /admin. Seems too easy to overwrite admin/plugins during an upgrade. I'm sure there's a good reason for it - just sayin'
Reply
#4
Well, i installed CustomFields - but i still dont know how do use it. Can you please make an example?
Reply
#5
Say you wanted to have a different header image on each page. You would have something like this on your theme.

Code:
<div id="header">
<img src="yourimage.jpg" alt="" />
</div>

Install the customfields plugin and edit or create /pages/other/customfields.xml
and add the following.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<channel>
<item><desc>image</desc><label>Header Image</label><type>text</type></item>
</channel>

Each <item> must have 3 parts,
desc - id of the customfield
label - what to display on the page edit form
type - type of field, either text or dropdown.
if type is dropdown add <option></option> tags with whatever you want in the dropdown menu

Now when you edit your pages you should have a new field "Header Image"

Change your template file to use the following instead

Code:
<div id="header">
<img src="<?php getCustomField('image');" alt="" />
</div>

Simple example, check out http://cmstest.digimute.com
which uses 3 new fields to create the portfolio - subtitle, image and jobtype.

Hope it helps, let me know if you need more info.

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#6
Ah, ok. Thats great - thanks.
Reply
#7
Hi all, first time posting, although I've had my eye on GetSimple for a while.

I'm developing a website for a client and was about to use my old standby CMS, but with this plugin I could possibly use GS. It's for an architect who has about forty odd projects he wants to feature, so I figured with a CustomFields plugin I could give him fields to plugin in "Project Name" "location" "Project Type", etc. for each of them

I'm trying to get this plugin working and I'm having a bit of a problem.

I can install the plugin with no problem and I see the fields boxes when I go to create a new page in the in the admin.

But nothing I do seems to let me display the info in the rendered template.

For example I created a custom field:
Code:
<item>
    <desc>projectname</desc>
    <label>Project Name</label>
    <type>text</type>
</item>

So in the template I put:

Code:
<?php returnCustomField('projectname'); ?>

correct? or do I use "getCustomField"? I'm a php noob and have no idea what the difference is...

Either way though, I've done both it returns nothing on the page.

Also, do I add ALL my custom fields in the "customfields.xml" file?

And if I do this:

Code:
<item>
<desc>pagetype</desc>
<label>Page Type (Blog/Gallery) </label>
<type>dropdown</type>

blog
gallery
</item>

as per the example on your blog, the dropdown box in the page admin is blank.

And once I get this working what are the html tags for the displayed custom fields? What are the css hooks so I can style them?

And lastly is there a character limit to the "text" option? And if so, can that be changed?

Thanks for your patience with my zillion questions.
Reply
#8
Hi,

Just realized I'd left some debug code in the original so the getCustomfield function returned nothing.. 8)

New version 1.1 is available here

http://www.digimute.com/index.php?type=b...e-2-plugin

The difference between the 2 functions is ;

getCustomField should echo the value to screen.
returnCustomField returns it to a variable.

As for the dropdown problem, the XML code rendering on my site is screwing up with the <option> tags so the full example should be
Code:
<?xml version=\'1.0\' encoding=\'utf-8\'?>
<channel>
<item>
    <desc>pagetype</desc>
    <label>Page Type (Blog/Gallery) </label>
    <type>dropdown</type>
    <option></option>
    <option>blog</option>
    <option>gallery</option>
</item>
<item>
    <desc>publishdate</desc>
    <label>Published Date</label>
    <type>text</type>
</item>
</channel>

All your customfields should be added to the one file between the <channel> tags.

Naming: each of the new fields has an id/name "post-" + fieldname so you can style.
No restrictions on the text size. Something I can add for the next version.

Hope this helps...
MIke.
My Github Repos: Github
Website: DigiMute
Reply
#9
Hi Mike,

Thanks for your answer. I did what you said and downloaded & installed the 1.1 version of the plugin. I can now display the text fields fine, but in the admin section I still get no selectable options in the dropdown box and it renders a blank line in the template . Here's my code in the customfields.xml:

Code:
<item>
    <desc>projecttype</desc>
    <label>Project Type</label>
    <type>dropdown</type>
    <option>Residential</option>
       <option>Commercial</option>
       <option>Estate</option>
</item>

Also in the rendered template, I see now the information I put in the admin in any text box displayed, but there are no html tags around it. So I am assuming the plugin doesn't add any unless that's how I code in in the template, correct?

So in the template I can put, for e.g.

Code:
<ul class="project-information">
<li><?php getCustomField('projectname'); ?></li>
<li><?php getCustomField('projectlocation'); ?></li>
<li><?php getCustomField('projecttype'); ?></li>
<li><?php getCustomField('projectdescription'); ?></li>
</ul>

And then I could use .project-information ul etc. to style the output? (if so this is great, perfect...just want to make sure that the plugin isn't supposed to be adding any div, p, etc. tags by itself my install isn't doing that...

Lastly the tag lets me output the content I put in the admin, is there a way to also display the "label", i.e something like this:

Code:
<ul class="project-information">
<li><?php SOMESORTOF PHPWIZARDRY 'projectname' label ?></li>
<li><?php getCustomField('projectname'); ?></li>
</ul>

So it would render like this on the webpage:
  • Project Name
  • Freds Project

Otherwise I can just handcode it I suppose ala:

Code:
<ul class="project-information">
<li>Project Name</li>
<li><?php getCustomField('projectname'); ?></li>
</ul>

But if I could pull out the 'label' from the custom field that'd be cooler...either way..

Thanks again...so it's just the why isn't the dropdown bit working..

Thanks again so much.
Reply
#10
Well I messed up again !!! 8)

In my rush to release the plugin I forgot to actually code the dropdown functionality...
My test version is running my initial code where it does work.

New version 1.2 can be downloaded now.

http://www.digimute.com/index.php?type=b...e-2-plugin

Which fixes the dropdown issue.

It doesn't style any of the output, thats up to you in the theme.

All the new fields should be available in the $tags Array in your theme.
so you should be able to use
Code:
echo $tags['projectname']['label'];   // output the label for the projectname field.
echo $tags['projectname']['type'];   // output the type of field
echo $tags['projectname']['value'];   // output the value of the field, can be used instead of getCustomField('projectname');

Hopefully this sorts it out...

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#11
Mike..

Thanks so much, everything is working great. Is there any way to control the size of the text field entry on the admin page options? For some a single line entry box is fine, but for longer text the size is a bit limiting...

Thanks
Reply
#12
Hi,

At least it all working fine now... 8)

As the form is built using a 2 column table were limited to 2 sizes, half and full size...
they will be available in the next version.

At the moment no, but you could set the css of the element.

Mike...
My Github Repos: Github
Website: DigiMute
Reply
#13
mike,

hi,

getSimple 2.01 rc3
customFields plugin 1.2

data/other/customfields.xml just one test text item like this one

<channel>
<item>
<desc>test</desc>
<label>test</label>
<type>text</type>
</item>
</channel>

Admin Side :
------------
a test page (testpage.xml), in the test custom field I add a value xxxx.
- Save Updates
- If I manually edit the testpage.xml, the custom fields xml tags and values are appended ->ok
- In the template <?php getCustomField('test');?> ->ok, return xxxx

the problem is : back to admin side / editing testpage / the custom fields always display blank values

I made several tests with different kind of inputedit : same problems, after saving a page, the custom fields values are not displayed on the admin side of a page.

this is not really a big problem but a very confusing one.
a createTagInputs() problem ?

hope my above text is explicit enough.

marc
marc
Reply
#14
latest version breaks the plugin as it uses $_GET['uri'] instead of $_GET['id']

So to fix if quickly.... just change line 118 of customfields.php , change 'uri' to 'id'

Will update the download version... couldn't figure it out myself earlier... 8)

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#15
correct now
thanks mike
marc
Reply
#16
guys, pls show some demo, i don't understand how it will be helpful in my site) Pls)
Reply
#17
It’s helpful if you want to have multiple fields to fill out when editing a page. That’s all. The plugin can be used to add as many custom fields as you want, those can be called from your template to display it at different places. So if you’re a developer and want to give a client just that extra option, you can add it to your template without having to change the GetSimple core.

Hard to make a demo, just give it a try.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#18
Ok, now im understand. Thank you Zegnåt! It's a helpful mod)
Reply
#19
Thanks noodle, works great. I added a textarea field type for my requirements.

Code:
case "textarea":
      echo '<td colspan="2">';
      echo "<b>".$tags[$key]['label'].":</b><br />";
      echo "<textarea id=\"post-".strtolower($key)."\" name=\"post-".strtolower($key)."\">".$data_edit->$key."</textarea></td>";
  break;
Modern UI Admin for GetSimple
Watch the demo. Install this plugin. Use this CSS. Enjoy.
Reply
#20
I'm curious of how hard it might be to add <template></template> to the xml file and then use custom templates to call corresponding custom fields in the "Page Options" area of 'edit.php'?

You would only display the custom fields that are assigned to a particular page template.

Does this make sense?
Reply
#21
It wouldn’t be so hard, but it wouldn’t really be easier to use. The problem is that the fields under Page Options are created when you first open a page to edit, so if you switch the page’s template it will not automatically go and check what tags might be needed. You’ll need to write some Javascript to keep everything in sync.
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply
#22
Custom fields are the weakest part of every CMS I've tried last few years. Unfortunately, without custom fields all we get is cloning a page and edit its main content. But if we are talking about a small website up to 10 pages, using CMS by an advanced web developer just doesn't make sense. It takes much less time and efforts, simply to write pages by hand and link them altogether. CMS is for people with little, or none knowledge of html, php, etc.
I can't wait for a good, workable and easy to install custom fields plugin.
Reply
#23
Cant see what could be much easier than whats there,

copy the plugin file to your plugin directory and create a single XML
file for your customfields.

What improvements would you like to see?

Mike.
My Github Repos: Github
Website: DigiMute
Reply
#24
Obviously it's not so easy. Zegnat says that it's hard to make demo.
You say in your site:
Quote:To use the new fields in your theme you can use the functions:

getCustomField($tag); // echos the returned value

or

returnCustomField($tag); // returns the value


What is this?
How to "use" it?
Put it in the page code, or theme code, or both?
Put them as they are, or between <? ?>?
I understand that when someone has been written a program he understands it, but not all of the others do.
Never mind.
Best regards.
Reply
#25
ragou Wrote:Obviously it’s not so easy. Zegnåt says that it’s hard to make demo.
Of course it’s hard to make a demo… I’ll have to give you access to my server to be able to take a look at the responsible XML-file, next I’ll have to give you access to my admin panel so you can see what happens when you change the contents of a custom field. It’s hard to demo, because it’s not obvious that a website is using the plugin if I just were to show you a GetSimple installation.

This has very little to do with how hard it is to use this plugin. Using it is pretty easy, demoing it stinks.

ragou Wrote:What is this?
It’s a plugin that enables you to add extra fields to the editing page of your admin section. Maybe you want to write a different copyright statement on all your pages, using this plugin you can add a field “Copyright” under “Page options” when you’re editing a page just for this!

ragou Wrote:How to "use" it?
You create a XML-file, as described on Mike’s plugin page, that tells the plugin what fields you would like to have added in the “Page options” box of your admin section. Now this extra data will be saved by GetSimple.

ragou Wrote:Put it in the page code, or theme code, or both?
Either in a component or directly into the theme’s file(s). These are the only places that accept PHP (unless you’re using the Exec-PHP plugin by Chris).

ragou Wrote:Put them as they are, or between <? ?>?
Mike assumes that, as he calls them functions and most people will be putting them in their theme’s template file(s), you realise he’s talking about PHP functions. These will always need to be defined as such by putting them between <?php (sometimes just <?) and ?>.

Hope this answers most of your questions!
“Don’t forget the important ˚ (not °) on the a,” says the Unicode lover.
Help us test a key change for the core! ¶ Problems with GetSimple? Be sure to enable debug mode!
Reply




Users browsing this thread: 1 Guest(s)