PHP code example of phproberto / joomla-entity
1. Go to this page and download the library: Download phproberto/joomla-entity library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
phproberto / joomla-entity example snippets
// Use article as entity
echo $article->get('title');
// Use params transparently
if ($article->param('show_title', '1') === '1')
{
echo $article->get('title');
}
// Check if article is featured
if ($article->isFeatured())
{
// Do something
}
// Check if article has an intro image
if ($article->hasIntroImage())
{
$image = $article->getIntroImage();
echo '<img src="' . JUri::root(true) . '/' . $image['url'] . '" />';
}
// Check article state
if ($article->isPublished())
{
echo 'Article published!';
}
// Retrieve article category
echo $article->category()->get('title');
// You can modify article properties
$article->set('title', 'My modified title');
// And save it
try
{
$article->save();
}
catch (\RuntimeException $e)
{
echo 'There was an error saving article: ' . $e->getMessage();
}