joomla - avoid model duplication between admin vs component packages - joomla

I'm developing a custom joomla component and have CRUD requirements on my database tables. In most of the examples i've seen, the default and admin pacakges both have their own model folders, and their seems to be a large amount of duplication. Is there a simple stragety to define the models and tables once within the admin section and then allow the default component to reuse the logic?

Hi you can reuse admin models by adding this into your front end component's main file:
$controller->addModelPath(JPATH_COMPONENT_ADMINISTRATOR.DS.'models');
You can reuse tables by adding this into your front end component's main file:
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');

Related

Getting CRUD data from laravel backpack to a new blade view page

I'm new to laravel backpack so what did is created a CRUD of title and description. And everything in admin panel works fine, but now I need to get that data to another blade view file through a controller like in a vanilla laravel but I cant seem to find how to do it.
If I understand your question correctly, there's absolutely NOTHING special you need to do - just do it "the normal Laravel way", by using your Model to query the database. It's usually something like Career::all() or Career::find($id) or Career::where('something', $value)->get(), depending on what you need to fetch from the database.
That's because Backpack uses your existing Eloquent Models, or creates the models if you don't have them already (usually in app\Models). So whenever you create/edit/delete an entry using the Backpack interface (aka CRUD), what Backpack does is use that Model to interact with the database. If you want to interact with the database, you should do the same thing - use the Model. That's the expected and recommended way of doing things in Laravel. To have Models for all your major database tables and do most (or all) of your interactions with the database using the Eloquent Models.
You can use view like this:
view('crud::show');
list, create etc.
all available files, you can find here: vendor/backpack/crud/src/resources/views/crud
If you want to override the template, please copy vendor template to your project
vendor/backpack/crud/src/resources/views/crud/show.blade.php > resources/views/vendor/backpack/crud/show.blade.php

How to generate scaffold RESTful view templates in Laravel like how RoR does?

Rails generates a folder of view template scaffolds when you run the cli command rails g controller User.
It will have view template scaffolding for create_user.html.erb, update_user.html.erb, list_user.html.erv....etc etc.
Is there anyway to have that same functionality in Laravel whether via a library, some included function, or a custom generator(or some other way)?
I'm using Laravel 5.4 if that makes a difference.
Since you're looking to generate views, I assume you're talking about a CRUD admin panel rather than an API. I highly recommend Laravel CRUD.
https://github.com/Laravel-Backpack/CRUD
This will allow you to create a model, controller, all routes, views etc with the command php artisan backpack:crud Model. It's super easy to use, but you'd want to probably start your project fresh - it assumes you're using it for the whole admin section, not just the views.

Joomla 1.5 - Creating SQL tables in components

Joomla 1.5 has JTable, which can be extended to act as an Active Record system (Create/Read/Update/Delete).
However, I can not find any way for this interface to create the table represented by my JTable sub-class.
Every example I have found has started with "manually create the database tables... ", then created a JTable class to work with it. I would like to be able to distribute my plugin and have it create the tables on setup, so that this is not necessary.
Any easy way to do this?
This is usually done in the install.sql of your extension (The link is related to component but I guess for plugins it's the same).

codeigniter: admin/cms as separate project or part of the same

So I've built a front-end to a website in Codeigniter, it has public and members areas.
Now it's time to build the backend administration where staff can manage some content: http://mysite.com/admin
At first I was going to just create subfolders within my controllers, models,views and resources folders for 'admin'
I'm wondering if I should just be doing a separate installation of CI for the admin? the layouts are different, the auth is different, sure they will share the same MySQL database but the admin will have different models and controllers
Best approach?
This article by Phil will give you a better idea:
http://philsturgeon.co.uk/blog/2009/07/Create-an-Admin-panel-with-CodeIgniter

How to design Joomla style plugin in CodeIgniter

First of all, I want to describe my project architecture:
My project uses jqGrid.
Controllers only define the Grid.
Then Models retrieve the Data for the Grid.
Models are used to Add/Edit/Delete Records.
Views are used to show the page.
Consider, I have 10 different kinds of customers for my project. My project is a hosted solution which serves my all 10 customers from a single source. Among them, eight needs the exact same as I created. Only two are different than the common.
For example, imagine that I want to show a product list. As my project is a hosted solution I can't change the menu by which I can change the controller for the said two customers.
To solve the problem, I want to implement plugin system like Joomla.
How can I do that in CodeIgniter?
Edit
I am using CI 1.7.2.
Maybe it will help you:
There is module solution for Codeigniter HMVC module . It gives you way to divide application logic into modules with their own MVC structure (each module will have it's own model\view\controller).
After installing this module into CI you'll be able to call another module from main app's controller (or view or model) like that:
<?php echo modules::run('module/controller/method', $param, $...); ?>
So I think you can use modules functionality provided by this extension to build per customer modules structure based on customers roles.

Resources