1. How to add more filters?
2. Using TextArea with RETURN delineated list which is inserted into Array? From Array to be displayed as a list again?
http://wordpress.org/extend/plugins/custom-content-type-manager/
1. How to add more filters?
2. Using TextArea with RETURN delineated list which is inserted into Array? From Array to be displayed as a list again?
http://wordpress.org/extend/plugins/custom-content-type-manager/
Do you mean Output Filters?
If you are using a TextArea, then you should NOT use an array filter. An array filter helps you operate on an array (e.g. the list of values stored in a multi-select field). A text field, a textarea field, or a WYSIWYG field is NOT an array. It's a string: it is a single value.
Just remember that all of the template functions and output filters are 100% completely unnecessary: they are only there for _convenience_. If you want to modify your data in a custom way, there are absolutely no limits to that: just add PHP code to your templates.
hey thanks for reply.
so how do i take the string of a textarea field thats delineated by return strings, and then use the delineated data in the list?
implode and explode etc ;)
You probably can't do that... I think WP strips out carriage returns when you save the form. If you use
tags, then you could just use the standard php implode and explode functions.
hi,
Lets say i have a custom text-area, where a poster can list items separated by commas:
eg: dogs, cats, birds, reptiles,
then i would like 2x filters to list them
eg. 1) dogs cats birds reptiles (horizontally)
eg. 2) dogs
cats
birds
reptiles (verticallY)
How can i do this?
I'd recommend that you try another approach: if you're using a text area, I'd recommend that you just enter the text as you want it to appear on the front-end. In other words, don't mess around with formatting and reformatting, especially if you're not a crack-shot with PHP string formatting functions.
You can lean on the Output Filters to help you out (see the Wiki), but there's nothing written to do exactly what you've described, especially not for a textarea. The closest I can recommend is the "formatted list" output filter that you can apply to a multi-select field, but again, I think you'll probably fly off the radar pretty quickly and need to know some PHP to do those kinds of customizations.
I know i can try shortcodes/bbcodes, but am eager to try taking the data from the database and reformat in a filter for display on the front end LOL
but if u gimme example I take a shot at doing implode/explode for the learning experience ? :)
Well, assuming you have a straight up textarea (not a WYSIWYG), then you can follow any tutorial from StackOverflow.com etc. but here's a quick example.
1. Enter in comma-separated values into your textarea custom-field, e.g. "man,bear,pig"
2. In your template file edit the PHP code. E.g.
print_custom_field('mytextarea');
prints out the contents of the field (or to be super-specific, if you want to ensure it's the raw content, without being filtered by one of the CCTM's output filters, you'd specify "raw" explicitly:
print_custom_field('mytextarea:raw');
But what you're asking for is something that modifies the contents... so first we're going to get that text from the textarea (not immediately print it):
<?php
$textarea = get_custom_field('mytextarea');
$array = explode(',',$textarea);
$output = ''; // initialize the variable
foreach ($array as $item) {
$item = trim($item); // clear off white-space
$output .= '<li>' . $item . '</li>';
}
// Now print the output:
?>
<ul>
<?php print $output; ?>
</ul>
Do you see what we're doing here? We're reading the string from the "mytextarea" field, we split the items into a PHP array by using the "explode" function, then we iterate over each item in the array, in this example, making an unordered list. Make sense? This is just PHP 101 stuff, nothing to do explicitly with the CCTM (other than the get_custom_field() function).
Cool, thanks for your help. I will give it a go later....So thats editing the templates directly??
what if i would like to set up a filter that does the html formatting
You can write your own custom output filters, but I haven't documented the process yet. The PHP approach above is much easier to follow. Creating a custom output filter requires that you jump into object oriented stuff. In other words, if you can't do the above, I wouldn't recommend that you try writing your own output filter.
hey, teach a man to fish for himself and he never goes hungry ;)
yeah, I have a ton to do with the code and then with the docs... but holy smokes I'm so slammed this week I can barely breathe.
Implement this in the way outlined above. It is MUCH easier. If you're at all shaky with PHP, then it is by far the better option for you. There's really nothing to lose doing it that way... writing your own Output filter makes sense in some situations, but there's not much benefit in this one. The only minimal benefit you'd get is a slightly cleaner template file, which in my mind, amounts to approximately zero benefit for all real intents and purposes.
You must log in to post.