Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#973 2012-03-14 05:34:44

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 859
Website

Re: glz_custom_fields

wow – I’ve amazed myself (nearly, sort of)

I can’t get your example to work, but using the my_images.php, I added a, “1” after the default value – as this changes it from a select to a multi select from what I can gather from the code.

This was the original my_images.php code:

  return glz_selectInput($custom_field, $custom_id, $images, $custom_value, "2");

and I changed it to this – and now its a multiselect

return glz_selectInput($custom_field, $custom_id, $images, $custom_value, "2", "1");

Hope that helps… but its probably worth getting this checked

Offline

#974 2012-03-14 15:33:59

mrdale
Member
From: Walla Walla
Registered: 2004-11-19
Posts: 2,215
Website

Re: glz_custom_fields

frickinmuck wrote:

I’m using this custom script to input categories as options on a select menu. How do I change it to a multi-select?

<?php
function list_clients($custom_field, $custom_id, $custom_value) {
    $categories = array();
    $query = safe_rows('name, title', 'txp_category', 'parent like "client"');
    foreach ($query as $category)
        $categories[$category['title']] = $category['title'];
    return glz_selectInput($custom_field, $custom_id, $categories, $custom_value, "");
}
?>

This is my script to grab all categories that have parent “XXX” and make a multi-select custom field out of them

<?php
function my_parents_cats($custom_field, $custom_id, $custom_value) {
  $titles = array();
  $query = safe_rows('name, title', 'txp_category', "parent like 'XXX' AND type like 'article'");
  $titles[] = '&nbsp;';
  foreach ($query as $title) 
    $titles[$title['name']] = $title['title'];
  return glz_selectInput($custom_field, $custom_id, $titles, $custom_value, "1", true);
}
?>

Offline

#975 2012-03-18 21:08:07

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: glz_custom_fields

I can’t get either of these approaches to work. Tye’s approach doesn’t seem to have any effect on the output – still comes up as a select menu. Dale, with yours I get the error:

“Ooops! list_clients() cannot be called. Ensure /html/scripts/glz_custom_fields/list_clients.php can be executed.”

Any ideas what could be going wrong? I’ve tried using this to change a pre-existing select menu into a multi-select, and I’ve also tried using it to set up an entirely new one from scratch, and neither approach is working.

EDIT: Never mind, I realized I hadn’t changed the name of your function to the one I was using. This is working now:

<?php
function list_clients($custom_field, $custom_id, $custom_value) {
  $titles = array();
  $query = safe_rows('name, title', 'txp_category', "parent like 'client'");
  $titles[] = '&nbsp;';
  foreach ($query as $title) 
    $titles[$title['name']] = $title['title'];
  return glz_selectInput($custom_field, $custom_id, $titles, $custom_value, "2", true);
}
?>

Thanks so much for your help, guys!

Last edited by frickinmuck (2012-03-18 21:11:49)


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#976 2012-03-18 21:37:49

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: glz_custom_fields

I just have one last question. How do I get it to separate the items differently in the database? Right now this:

<?php
function list_clients($custom_field, $custom_id, $custom_value) {
  $titles = array();
  $query = safe_rows('name, title', 'txp_category', "parent like 'client'");
  $titles[] = ' &nbsp; ';
  foreach ($query as $title) 
    $titles[$title['title']] = $title['title'];
  return glz_selectInput($custom_field, $custom_id, $titles, $custom_value, "2", true);
}
?>

Results in something that looks like this: First Client Name|Second Client Name|Third Client Name, and I’d like to be: First Client Name, Second Client Name, Third Client Name. Any ideas?


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#977 2012-03-18 22:16:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: glz_custom_fields

frickinmuck wrote:

First Client Name|Second Client Name|Third Client Name

That’s the contents of your custom field, and you need to output it somewhere, right? In that case I’d resort to one of our Swiss army k…atalyzers, rah_replace or smd_wrap.


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#978 2012-03-18 22:30:01

frickinmuck
Member
Registered: 2008-05-01
Posts: 118

Re: glz_custom_fields

Yeah, I guess I can use rah_replace, but I was hoping there would be a way to achieve this from the outset. i.e. separate the categories being input into the custom field with something other than the | with no spaces around it. Something about having them entered that way in the db bugs me.

Last edited by frickinmuck (2012-03-18 22:30:27)


The AI does not hate you, nor does it love you, but you are made out of atoms which it can use for something else.

Offline

#979 2012-03-19 07:15:36

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: glz_custom_fields

That’s the way it comes out of glz_custom_fields rather than out of the db so you’d likely have to edit the plugin to get different output.

If you already have code setup to work with a comma-separated list, you can convert it to a comma-separated txp:variable using what Uli said and plug that variable into your code. Alternatively rah_repeat and smd_each can also process each item without pre-converting to commas.


TXP Builders – finely-crafted code, design and txp

Offline

#980 2012-03-25 17:06:23

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: glz_custom_fields

I’ve been reading the 50 first pages of this thread this afternoon, trying to figure out what the plugin does and what it doesn’t. Nearly 48 pages left and probably other answers in them, but this is what I understood so far, and what I still wonder :

  • it is a back-end plugin and there’s no front-end tag provided (though it used to)
  • more than 10 custom fields can be set and used ; edit: not only as text fields but also as radio sets, checkboxes
  • contributors (i.e. paid users) have to subscribe to the dedicated Google group to get new versions
  • is the link to contribute, in the first post, still valid ?

Thank you !

Last edited by CeBe (2012-03-26 07:09:14)

Offline

#981 2012-03-25 19:45:44

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 4,726
Website

Re: glz_custom_fields

:-) yeah, some threads have grown insanely long. The primary advantage – aside from being able to have more than 10 custom fields (which you access with the normal txp:custom_field tag) – is the ability to make custom fields appear as other kinds of fields on the write tab and the ability to pre-populate the available choices … as described in the opening post. There’s one aspect not shown in the screenshots, and that is the ability to have your select box driven by a custom script of your own making (examples are provided) that pulls in data from elsewhere in the database.
I’ve only rarely accessed the google group, but the fee really is very reasonable and you need only pay once.


TXP Builders – finely-crafted code, design and txp

Offline

#982 2012-03-25 23:15:12

uli
Moderator
From: Cologne
Registered: 2006-08-15
Posts: 4,306

Re: glz_custom_fields

CeBe wrote:

  • more than 10 custom fields can be set and used

The true value of this plugin is not the 10+ text input fields but the ease of use you permit to your clients by letting them click checkboxes and radio buttons, let them choose from predefined dropdown menus and select lists, enter dates via clickable calendars and times from preset menus.
Instead of the old error prone way of letting them enter these values by hand. Into 10+ good old TXP text input fields.

But if it’s just about these 10+ fields then TXP has all you need and you don’t have to buy anything. You just need some boldness and knowledge to run the right MySQL queries (and maybe G-translate).

  • contributors (i.e. paid users) have to subscribe to the dedicated Google group to get new versions

As far as I can remember you get access/the plugin by mail as soon as Gerhard has received your payment. The Google group serves only as a “counter” for feature ideas and as bug tracker (again: AFAICT).

  • is the link to contribute, in the first post, still valid ?

I assume that people that have subscribed here have used the link ages ago ;) (you pay once for a lifetime).


In bad weather I never leave home without wet_plugout, smd_where_used and adi_form_links

Offline

#983 2012-03-26 07:30:51

CeBe
Plugin Author
From: Caen - Fr
Registered: 2010-06-25
Posts: 345
Website

Re: glz_custom_fields

Thanks Jakob and Uli.

It was so obvious that custom fields can be used as checkboxes or radio sets – too obvious – that I forgot to mention it. It’s done now.
I’m convinced that the fee is worth it, and is even extremely low considering the work done. All I want is to ensure that the plugin will suit my needs.

So, what are these needs ?:)
Basically, I’d like to perform searches on custom fields (and-searches on absolute values and ranges).
Admin-side checkboxes and radio buttons are a plus.

Continue reading the last ~50 pages now :) I’m pretty sure answers are in them.

Offline

#984 2012-03-26 07:43:54

philwareham
Core designer
From: Haslemere, Surrey, UK
Registered: 2009-06-11
Posts: 3,564
Website GitHub Mastodon

Re: glz_custom_fields

Gerhard is responsive on twitter if you need to ask him a question directly in 140 characters: @gerhardlazu

Offline

Board footer

Powered by FluxBB