Skip to content

Commit

Permalink
Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Hibberd committed May 28, 2014
1 parent d6ec489 commit cee4da5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ Each link returns a link object which contains the following:

## Changelog

### 0.6

* Fix: PHP Error when returning an entry or asset that has subsequently been deleted

### 0.5

Expand Down
2 changes: 1 addition & 1 deletion linkit/LinkitPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public function getName()

public function getVersion()
{
return '0.5';
return '0.6';
}

public function getDeveloper()
Expand Down
13 changes: 7 additions & 6 deletions linkit/fieldtypes/Linkit_LinkitFieldType.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,11 @@ public function getSettingsHtml()

return craft()->templates->render('linkit/_fieldtype/settings', array(
'types' => $this->getLinkitTypes(),
'settings' => $this->getSettings(),
'entrySources' => $this->getElementSources($entryElementType),
'entryTargetLocaleField' => $this->getTargetLocaleFieldHtml($entryElementType, $this->getSettings()->entryTargetLocale, 'Entry'),
'assetSources' => $this->getElementSources($assetElementType),
'assetTargetLocaleField' => $this->getTargetLocaleFieldHtml($assetElementType, $this->getSettings()->assetTargetLocale, 'Asset'),
'settings' => $this->getSettings(),
'settings' => $this->getSettings()
));
}

Expand Down Expand Up @@ -274,6 +273,7 @@ public function prepValue($value)
{

// Process Entry Field - Criteria
// TODO - Should I Be Using the craft()->entries->getEntryById( $entryId )
$entryCriteria = craft()->elements->getCriteria(ElementType::Entry);
if($value['entry'] && $value['type'] == 'entry')
{
Expand All @@ -291,6 +291,7 @@ public function prepValue($value)
$entryCriteria->id = false;
}
$value['entryCriteria'] = $entryCriteria;



// Process Asset Field - Criteria
Expand Down Expand Up @@ -378,7 +379,7 @@ public function prepValue($value)
break;

case('entry'):
if($entryCriteria->id)
if($entryCriteria->first())
{
$value['entry'] = $entryCriteria->first();
$value['url'] = $entryCriteria->first()->getUrl();
Expand All @@ -393,15 +394,15 @@ public function prepValue($value)
break;

case('asset'):
if($assetCriteria->id)
if($assetCriteria->first())
{
$value['entry'] = $assetCriteria->first();
$value['asset'] = $assetCriteria->first();
$value['url'] = $assetCriteria->first()->getUrl();
$value['linkText'] = ($value['text'] ? $value['text'] : $assetCriteria->first()->title);
}
else
{
$value['entry'] = false;
$value['asset'] = false;
$value['url'] = false;
$value['linkText'] = ($value['text'] ? $value['text'] : '');
}
Expand Down

0 comments on commit cee4da5

Please sign in to comment.