As an aside, please commit your changes to the plugin so far. The CID
plugin is the only one I've not yet renamed, mostly because I don't
want to mess up your work by renaming it without coordinating with
you. Also, however, I'd get a chance to see the context for this
question.
Once renamed, it will be here:
http://svn.wp-plugins.org/scriblio-schema-cid/
Anyway, back to your question...
This add_filter call probably looks funny because it's calling the
method of an object:
> add_filter( 'the_content', array(&$this, 'cid_the_content'));
For the CID plugin, it could probably look like this:
add_filter( 'the_content', 'cid_the_content' );
And this function definition is also written to be part of an object:
> public function cid_the_content( $content ) {
For the CID plugin, you can probably drop "public".
And this function call could be rewritten without the "$this->"
> return( $this->cid_parse_content( $r['cid'] ));
I might be able to offer a better example, however. Take a look at
this site, then read on:
The schema here is "phonebook". I'd started out thinking it would be a
generic people directory, but time and other complications focused it
more specifically on the needs of that one marketing website. Still,
it's tracking a few details and uses WordPress' built-in content field
for the person's description. Even better, it's not written as a class
and has none of the OOP syntax. Here's how the various bits of data
get assembled:
add_filter( 'the_content', 'phonebook_the_content', 1);
function phonebook_the_content( $content ) {
global $id;
if( $id && ( $r = get_post_meta( $id, 'scrib_meditor_content',
true )) && is_array( $r['phonebook'] )){
global $bsuite;
$place = array();
$facebookid = '';
$phonebook = '<p class="academics">';
if ( is_array( $r['phonebook']['hometown'] )){
foreach( $r['phonebook']['academic'] as $temp )
if( !empty( $temp['class'] ))
$phonebook .= '<span class="graduating">Class of '.
$temp['class'] .'</span>';
if( !empty( $temp['major'] ))
$phonebook .= '<br /><span class="major">'. $temp['major'] .'</
span>';
}
$phonebook .= '</p>';
if ( is_array( $r['phonebook']['hometown'] )){
foreach( $r['phonebook']['hometown'] as $temp ){
if( !empty( $temp['highschool'] ))
$phonebook .= '<p class="highschool">'. $temp['highschool'];
if( !empty( $temp['city'] ))
$place[] = $temp['city'];
if( !empty( $temp['state'] ))
$place[] = $temp['state'];
}
}
if ( is_array( $r['phonebook']['contact'] )){
foreach( $r['phonebook']['contact'] as $temp ){
if( !empty( $temp['facebookid'] ))
$facebookid .= '<div class="facebook"><a href="'.
$temp['facebookid'] .'" title="Find me on Facebook!">Find me on
Facebook</a></div>';
}
}
if ( is_array( $place ))
$phonebook .= '<br />'. implode( ', ', $place ) .'</p>';
else
$phonebook .= '</p>';
return( '<div class="sub">'. $phonebook .'</div>'. $content .
$facebookid );
}
return( $content );
}
> Changes to scriblio-meditor-cid have been committed. I'll update my
> svn to scriblio-schema-cid, if you are ready to rename the plugin.
Sweet. I've moved and renamed the plugin:
http://svn.wp-plugins.org/scriblio-schema-cid/
http://wordpress.org/extend/plugins/scriblio-schema-cid/
I also did a little work on it. the_content now works a bit (see
below). I've also remove a bit of extraneous code that I should have
cleared out previously.
> The cid_the_content function is very stripped down now, in hopes of
> not confusing myself.
I've gone and made it a bit more complex. It can now generate some
basic HTML for the locations and facilities. It's not much, but it's a
start.
> - I'm confused about the add_action that refers to cid_save record:
> why doesn't it use the Wordpress action save_post?
Scriblio uses the save_post action and preprocesses the Meditor
inputs, then Scriblio calls a x_save_record action for each of the
Meditor forms it finds, that's where cid_save_record comes in.
> I also have a bit more information from the tests I've been doing. I'm
> just trying to enter data into the CID form and publish the post. A
> post is created, and I can see its title in my database as well as in
> the browser, but the post doesn't have content.
It was looking for $r[$cid], but should have been looking for
$r['cid']. Things seem to be working with that change.
The cid_the_content() function that assembles the data from
wp_postmeta is run as the post is actually being displayed, not as
it's being saved.
So there's no need to worry about having nothing in the post_content
field, but is the real issue that nothing is getting displayed when
you view the record in your browser?
> Casey,
> Huge thanks for helping me figure this problem out; screenshots of
> successful displays are attached.
>
> I will be committing new CID code this evening which fills out the
> data model.
I'm glad it's working!
> My next two priorities are mapping to the III importer and getting
> search/browse to work (currently browse and search return 404
> errors). Just so I know where to direct my energies, could you tell
> me whether I should expect Browse to work at this point? In other
> words, should the Scrib browse functions be working for my CID
> plugin, or do I need some additional code in CID to make that happen?
The problem with the browse page may be that the permalinks aren't
configured or haven't updated properly after the Scriblio install. If
you already configured permalinks, simply visiting the permalink
options page again should be enough to update the settings, but making
(and reverting) a small change would help. If you don't have
permalinks setup, make sure you're using anything other than the ?
p=123 style.
I've posted a bit about .htaccess here:
http://about.scriblio.net/wiki/htaccess/
There's a chance that your Apache config is set to ignore .htaccess
files. You'll need to look at your directory or virtual host settings
in the Apache conf file. "AllowOverride None" will block .htaccess
access files, so you'll need to change those to something less
restrictive (I boldly set them to "All") and restart Apache.
--Casey
There are at least two ways to get a 404:
A. because Apache doesn't find a file to serve the request (gives a
rather bland 404 page)
B. because WordPress finds no posts for the the request (gives a 404
page using the WP theme)
I think you're suffering from cause B, and I probably should have
thought of this earlier.
Scriblio records are expected to be in a certain category set in the
Scrib options page. That's used to keep them off the front page[1] and
select them for browsing[2]. But the CID schema isn't setting the
category when it saves the record, leaving WordPress to issue the 404
on the browse page because it can't find any records in the required
category.
All we need to do to fix this is make sure the CID records are in that
category. The Marcish schema does that during the
scrib_meditor_save_record hook[3] like this:
wp_set_object_terms( $post_id, (int) $this-
>options['catalog_category_id'], 'category', FALSE );
I've committed a change[4] to CID to fix that, as well as a change[5]
to fix a bug (I had made long ago) in how it was displaying repeated
fields.
I should have made both changes a while ago, or at least identified
the cause of the 404s more quickly,
--Casey
[1]: http://plugins.trac.wordpress.org/browser/scriblio/trunk/scriblio.php#L448
[2]: http://plugins.trac.wordpress.org/browser/scriblio/trunk/scriblio.php#L393
[3]: http://plugins.trac.wordpress.org/browser/scriblio/trunk/scriblio.php#L2827
[4]: http://plugins.trac.wordpress.org/changeset/127354/scriblio-schema-cid/trunk
[5]: http://plugins.trac.wordpress.org/changeset/127364/scriblio-schema-cid/trunk
On Jun 18, 2009, at 5:18 PM, Shannon wrote:
Sorry I wasn't specific in my previous messages.
Sent from my iPhone