CodeIgniter Forums
Creating widgets containing links to pages - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: General Help (https://forum.codeigniter.com/forum-24.html)
+--- Thread: Creating widgets containing links to pages (/thread-72348.html)



Creating widgets containing links to pages - Ajax30 - 12-07-2018

I've made an open-source blogging application and I need some help with it. The application supports not only posts, but pages too.

also uploaded an instance of the application, with dummy content, on my server. Click on HERE to see it.

The concrete problem: in the footer of the site I display some pages (not posts). The way I display them is unsatisfactory for me, because it implicates hardcodeing:

   

Code:
<div class="col-sm-6 col-md-3">
      <h3>Legal</h3>
       <ul class="list-unstyled">
       <?php foreach ($pages as $page): ?>
        <li><a href="<?php echo base_url('pages/page/') . $page->id; ?>"><?php echo $page->title; ?></a></li>
       <?php endforeach; ?>
      </ul>
   </div>    


This allows me to display the pages in only one "box". Maybe I would find a solution that lacks... elegance (it would involve some if statements) to display two pages in each box


Perhaps widgets (like WordPress has) would be a good idea. Widgets in which I could drag-and-drop (links to) pages and other entities. I have not found any tutorials on making widgets in Codeigniter.

I don't now if CI has helpers or any other features to support widget creation. I am a beginner (intermediate at best) PHP developer so I don't know where to start creating this feature. Please help. Come with the best approaches.


RE: Creating widgets containing links to pages - InsiteFX - 12-07-2018

If you download and setup HMVC by Wiredesignz

Modular Extensions - HMVC

He had a Widgets class to work with it.

Widget Code is here

You might be able to re-write the Widget library and make it a stand alone one.

UPDATE:

Here is another one I just found.

CodeIgniter Widget (View Partial) Sample

Here is a newer one for CodeIgniter 3x.

CodeIgniter Widget