Customized layout with PHP
PHP - using Blocks
If you are a developer and are used to code with entity collection, addAttributeToFilter, and addAttributeToSelect methods, this section is made for you.
You can easily integrate a list whether by using Blackbird\ContentManager\Block\ContentList
or extends Blackbird\ContentManager\Block\Content\Widget\ContentList block
or by using calling directly a Content collection Blackbird\ContentManager\Model\ResourceModel\Content\CollectionFactory.
<span class="variable">$_objectManager</span> = \Magento\Framework\App\ObjectManager::getInstance(); <span class="comments">//instance of\Magento\Framework\App\ObjectManager</span>
<span class="variable">$contentCollection</span> = <span class="variable">$_objectManager</span>->create(<span class="string">'Blackbird\ContentManager\Model\ResourceModel\Content\CollectionFactory'</span>);
<span class="variable">$collection</span> = <span class="variable">$contentCollection</span>->create()
->addContentTypeFilter(<span class="string">'news'</span>)
->addAttributeToFilter(<span class="string">'status'</span>, 1)
->addAttributeToSelect(<span class="string">'title'</span>)
->addAttributeToSelect(<span class="string">'url_key'</span>)
->addAttributeToSelect(<span class="string">'image'</span>);
PHP - Directly into a .phtml theme file
You can call on content directly into a theme .phtml file using Blackbird\ContentManager\Model\ResourceModel\Content\CollectionFactory. This example uses news as the *identifier* and also uses ->setPageSize() & ->setCurPage() to limit the content.
<span class="variable">$_objectManager</span> = \Magento\Framework\App\ObjectManager::getInstance(); <span class="comments">//instance of\Magento\Framework\App\ObjectManager</span>
<span class="variable">$contentCollection</span> = <span class="variable">$_objectManager</span>->create(<span class="string">'Blackbird\ContentManager\Model\ResourceModel\Content\CollectionFactory'</span>); <span class="variable">$collection</span> = <span class="variable">$contentCollection</span>->create()
->addContentTypeFilter(<span class="string">'news'</span>)
->addAttributeToFilter(<span class="string">'status'</span>, 1)
->addAttributeToSelect(<span class="string">'title'</span>)
->addAttributeToSelect(<span class="string">'url_key'</span>)
->addAttributeToSelect(<span class="string">'image'</span>);
->setPageSize(2)
->setCurPage(1)
foreach (<span class="variable">$collection</span> as <span class="variable">$_content</span>){
<span class="function">print_r</span>(<span class="variable">$_content</span>->getData()).<span class="string">'<br></br>'</span>;} 