Recent Topics

1 Jul 10, 2006 02:18    

Back in the 1.6 days I updated an old Creative Commons License plugin to work with that version. The CCL people say (or said) it's better to have your license not use the generic text for some reason or other, so I made my plugin have the option of using 'regular' or 'advanced'. Advanced license text very simply included the author's preferred name and linked it to all their posts in that blog. This is the core of how that worked:

if( $this->advanced_settings ) {
	global $Item, $Blog;
	}


In this plugin that value was false unless the user wanted the 'advanced' text. Anyway later on in the plugin I did this:

$license_text = 'This post is licensed under a '; // edit as you see fit for your generic license
if( $this->advanced_settings ) {
	$auth_pref_name = $Item->Author->get_preferred_name();
	$auth_linked_name = '<a href="'.$Blog->get( 'blogurl', 'raw' ).'?author='.$Item->Author->get('ID').'" title="'.T_('Browse all posts by').' '.$auth_pref_name.'">'.$auth_pref_name.'</a>';


It worked. If the user (admin) edited the plugin file and chose made "advanced_setting" be 'true' they got the post author's preferred name linked to their posts in that blog as part of their license.

It doesn't work in 1.8, and I can't figure out why. Admittedly I've only tried a little, but since I have to go to work in about 5 minutes I figured I'd ask here and see if anyone is hip to the new code enough to help me out.

So far I've made the "generic or advanced" be a drop-down in the plugin settings, and I know I can change and access that value.

if( $this->Settings->get('cc_license_type') == 'advanced' ) {
	global $Item, $Blog;
	}


That works because I had a simple echo inside that showed up after I changed to advanced. Problem is the next part fails.

if( $this->Settings->get('cc_license_type') == 'advanced' ) {
	$auth_pref_name = $Item->author();
	$auth_linked_name = '<a href="'.$Blog->get( 'blogurl', 'raw' ).'?author='.$Item->User->get('ID').'" title="'.T_('Browse all posts by').' '.$auth_pref_name.'">'.$auth_pref_name.'</a>';

It has failed on the line for "auth_pref_name" with quite a few random guesses at what it should be, so I don't even know if I'm guessing in the right area. Any help will be greatly appreciated AND rewarded. Yup: a reward! The person who helps me figure out this (probably simple) problem will win a FREE zip-wrapped copy of the plugin!!!

2 Jul 10, 2006 05:57

<?php echo $Item->Author->get_preferred_name(); ?>

But if i remember correctly you need to activiate the user/author first...

EDIT: Ok i don't think you need to activate the author first... I wonder what u need to activate them for then.... (Haven't skinned for a while :oops: )

EDIT 2: Why would this be in plugin assistance? When the question has nothing to do with plugins...

3 Jul 10, 2006 07:54

Hi EdB,
The cc plugin works fine on our test 1.8 site using this code

						if( $this->Settings->get( 'advanced_settings' ) ) {
							$Item->get_creator_User();
							$auth_pref_name = $Item->Author->get_preferred_name();
							$auth_linked_name = '<a href="'.$Blog->get( 'blogurl', 'raw' ).'?author='.$Item->Author->get('ID').'" title="'.T_('Browse all posts by').' '.$auth_pref_name.'">'.$auth_pref_name.'</a>';
							$license_text = 'This post is the creative work of '.$auth_linked_name.' and is licensed under a ';
							}

¥

*edit*
corected code

4 Jul 10, 2006 15:54

Thanks ¥åßßå - I'll check it out. I saw some references to *_creator_* but hadn't tinkered with them yet. I still haven't got a grip on how the new file structure does it's thing. First they took away b2evocore/evocore, now they took away admin. I'm lost!

Balupton it's for a plugin is the thing. Creative Commons License on a post-by-post basis. Back in the day "Author" was valid, but now it seems to have become "User", but - as I said just a paragraph ago - I'm lost in the new structure.

Anyway the 1.6/1.7 version seemed to work in 1.8 but I wanted to take advantage of all the pluginability that 1.8 enables. So now it'll ship with a specific default license and display method but each installation will be able to change them in the back office. Same with the 'generic' or 'advanced' license text. After I test ¥åßßå's code I'll see if it's worth it to tinker up a way to *completely* customize the 'advanced' version just because it'd be cool.

Wow! It's almost 7 in the morning and I'm still completely sober 8|

5 Jul 10, 2006 16:40

Wow! It's almost 7 in the morning and I'm still completely sober

8| *hands a JB* ..... jeez mate, you really shouldn't shock your system like that

¥

6 Jul 10, 2006 16:46

¥åßßå wrote:

Wow! It's almost 7 in the morning and I'm still completely sober

8| *hands a JB* ..... jeez mate, you really shouldn't shock your system like that

¥

Pfff, people do their best coding when they pass the sleep barrier ;) (Hugs 4am coding)

7 Jul 11, 2006 01:33

Thanks ¥åßßå!!!

Your code was enough to get the whole thing working as a real live actual factual plugin. Groovy! I'll PM you with a link to your own private zip of 1.8.¥ and work on making a public release after that.

The only thing lacking for a public release, btw, is a link to an explanatory help page. I'm not sure if I want to promote myself by linking to a blog post or the manuwiki by linking to a page there.


Form is loading...