file About article description and keywords fields

More
9 years 11 months ago #4131 by FabZ
Hello Carsten888,
In my opinion article description and keywords are very important fields for article diffusion.
On JED there are different plugins they complete those fields for any article, they have a lot of settings, custom filters, personalized whitelist and/or blacklist etc etc and any time you save article you have autocompleted description and keywords fields.

I think this operation is not for any generic publisher, I mean to insert descriptions and, expecially, keywords.

With PI component (but I can say with any "form to content" component) any specific plugin fails to intercept content and add description and keywords.
I use Add Keywords plugin, I mentioned that one because I know it works for backend and for frontend but I know there are several different extensions.
May I ask to you what do you think it could be better solution for this drawback?

Kind regards,
Fabrizio

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #4136 by carsten888
Replied by carsten888 on topic Re:About article description and keywords fields
I've looked into this, but to get PI to work with Joomla's onAfterDisplayContent-event I would have to re-write the entire article-save function which is really a lot of work and I got little time these days. So don't count on anything. Sorry.

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #4157 by FabZ
Well, I didn't think to re-write PI it could have been a feasible path :P

At current time I imagined two option:
- to re-open/save PI created articles in Article Manager, maybe with a cronJ procedure.
- to force AddKeywords to work with PI.

For me, at current time, it's science fiction lol
but I will investigate and try.

Regards :)
Fabrizio

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #4189 by carsten888
Replied by carsten888 on topic Re:About article description and keywords fields
here is a fix that will make this work for AddKeywords:

Pages-and-Items version 1.5.4
file: administrator/components/com_pi_pages_and_items/class.php
line: 1093
$show_title_item = intval($this->get_var('show_title_item'));	
		$item_on_frontpage = intval($this->get_var('frontpage'));

replace with:
$show_title_item = intval($this->get_var('show_title_item'));	
		$item_on_frontpage = intval($this->get_var('frontpage'));			
		
		//call onBeforeContentSave-event to work with add-keywords-plugin
		$row = & JTable::getInstance('content');
		$row->id = $item_id;
		$row->title = $title;
		$row->introtext = $introtext;
		$row->fulltext = $fulltext;
		$row->sectionid = $section_id;
		$row->catid = $cat_id;
		$row->metakey = $metakey;
		$row->metadesc = $metadesc;
		$isNew = 0;
		if(!$item_id){
			$isNew = 1;
		}
		$dispatcher = & JDispatcher::getInstance();
		$result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew));
		$metakey = $row->metakey;
		$metadesc = $row->metadesc;


I'm not sure to what extend this would conflict with other plugins which use the 'onBeforeContentSave'- event, as most of the data is not parsed. So if you are using this and it works fine (or not) please post back here. If this fix seems stable I will include this in a next version of PI. But for now I will uncomment the code.

enjoy!

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #4197 by FabZ
Hello Carsten,
I tested code and it seems it allows to take keywords from title (additional Add Keywords keywords option) but not from content and it doesn't work for content description, adding "..." only (other option from Add Keywords setting to close description).

Please Log in or Create an account to join the conversation.

More
9 years 11 months ago #4199 by carsten888
Replied by carsten888 on topic Re:About article description and keywords fields
It worked for normal text items, but for custom-item-types the content first needs updating, so this code needs to go after that.

So undo the above hack and find these lines:
(about 1313)
if(method_exists($class_itemtype,'item_save')){							
				$class_itemtype->item_save($item_id);
			}	
		}

replace by:
if(method_exists($class_itemtype,'item_save')){							
				$class_itemtype->item_save($item_id);
			}	
		}
		
		
		//call onBeforeContentSave-event to work with add-keywords-plugin
		//I know this should actually be loaded before the content is saved, but then the output of the
		//custom item types would be ignored
		//so here is a sort of workaround
		$this->pi_config['use_addkeyswordsplugin'] = 1;//this will be included in the config if this is included in a future version
		if($this->pi_config['use_addkeyswordsplugin']){
			$row = & JTable::getInstance('content');
			$row->id = $item_id;
			$row->title = $title;		
			
			//get the actual output
			$this->db->setQuery("SELECT introtext, `fulltext` "
			."FROM #__content "
			."WHERE id='$item_id' "
			."LIMIT 1 "
			);
			$rows_items = $this->db->loadObjectList();
			foreach($rows_items as $row_item){	
				$row->introtext = $row_item->introtext;
				$row->fulltext = $row_item->fulltext;
			}	
			
			$row->sectionid = $section_id;
			$row->catid = $cat_id;
			$row->metakey = $metakey;
			$row->metadesc = $metadesc;
			$isNew = 0;
			if($new_or_edit = 'new'){
				$isNew = 1;
			}
			$dispatcher = & JDispatcher::getInstance();
			$result = $dispatcher->trigger('onBeforeContentSave', array(&$row, $isNew));
			$metakey = $row->metakey;
			$metadesc = $row->metadesc;
			
			$this->db->setQuery( "UPDATE #__content SET metakey='$metakey', metadesc='$metadesc' WHERE id='$item_id' ");
			$this->db->query();
		}

Now also the content rendered by custom itemtypes is considered. So make sure there is some content there, because if it is just an image or so, its not going to make keywords from that, so add a text field or so.

Please Log in or Create an account to join the conversation.

Time to create page: 0.138 seconds
Powered by Kunena Forum
 
spicy-sacerdotal