Textpattern Forum

You are not logged in. Register | Login | Help

#971 2012-02-19 15:00:28

philwareham
Core designer
From: Farnham, Surrey, UK
Registered: 2009-06-11
Posts: 1,582
Website

Re: glz_custom_fields

Just a suggestion for an improvement:

Although you can override the default install directory (/plugins) for certain glz_custom_fields files (I use /textpattern/glz_custom_fields as I like to keep things out of the root directory as much as possible) the plugin still looks for some of it’s files within the default /plugins folder.

Need a way to override that really, at the moment I have to manually edit the plugin code to point to my preferred directory.

Cheers,
Phil

Last edited by philwareham (2012-02-19 15:01:03)

Offline

#972 2012-03-13 16:38:14

frickinmuck
Member
From: Vancouver, BC
Registered: 2008-05-01
Posts: 105
Website

Re: glz_custom_fields

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, "");
}
?>

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

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

tye
Member
From: Pottsville, NSW
Registered: 2005-07-06
Posts: 813
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
Moderator
From: Walla Walla
Registered: 2004-11-19
Posts: 2,059
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
From: Vancouver, BC
Registered: 2008-05-01
Posts: 105
Website

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
From: Vancouver, BC
Registered: 2008-05-01
Posts: 105
Website

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/Köln
Registered: 2006-08-15
Posts: 3,047

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
From: Vancouver, BC
Registered: 2008-05-01
Posts: 105
Website

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
Moderator
From: Germany
Registered: 2005-01-20
Posts: 1,898
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: 285
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

Board footer

Powered by FluxBB