codeigniter admin template - templates

Hello all im using this template system
http://williamsconcepts.com/ci/codeigniter/libraries/template/index.html
but now i want to add a admin system to it, how would you do that?
make a map in controller/model and view calling "admin" but how can i then use the template system without conflicts :O?.
do you know a better way i will be glad if you will tell :)
Thanks a lot

Yes, you can create a view called admin and a controller called admin; there will be no conflicts.
Using a template library, you will want to do something like this:
In config/template.php
$template['admin']['template'] = 'admin/admin_template.php'; // in your views
// create a new template and its regions
$template['admin']['regions'] = array(
'header',
'content',
'footer',
);
then in your admin controller:
class Admin extends CI_Controller { //ci 2.0
function __construct()
{
parent::__construct();
$this->load->library('template');
$this->template->set_template('admin'); // set the admin template
}
// carry on as normal
}

i set up my routes to go through /admin and the actions that are for admins are in /views/admin/modelname
I also use tankAuth it's very good.

Related

Custom form field in views

I'm trying to create a custom field for a view in Drupal 8 which allows to perform an action without changing the page (link). I guess I have to create a form inside that custom field but I do not know how to achieve it.
Any idea on how to do it or other alternative without redirecting to a route?
The view will be a list of custom entities and I need a button for each of the lines.
Thanks in advance!
Finally I solved it by following this steps:
I created a view custom field (generate:plugin:views:field with
drupal console)
I created a form (generate:form)
Then, in the view custom field render function return the form:
$form = \Drupal::formBuilder()->getForm('Drupal\test_module\Form\TestForm', $values->_entity->ID());
return $form;
It's important to notice that an incremental (dynamic) formId is needed for things to work properly. I did that by creating a static variable and a __construct() method as follows:
protected static $instanceId;
public function getFormId() {
return 'my_form_id_' . self::$instanceId;
}
public function __construct(){
if (empty(self::$instanceId)) {
self::$instanceId = 1;
}
else {
self::$instanceId++;
}
}

Add CMS menu item with fields in Silverstripe 3.6

Still a newbie in Silverstripe. I am experimenting with the CMS and I would like to create a new CMS menu with text fields in it. I managed to add a CMS menu item with a gridfield in it to add data objects but what I require is to have text fields directly inside the CMS menu item without creating a Data Object (similar to the Settings menu as shown in the image below)
Can someone guide me in what I need to extend and how to set the thing up? Many thanks in advance.
You can extend the settings section. The following example adds a tab called Social Media under the settings section and 2 fields FacebookURL and TwitterURL. You can change this to any fields / tabs that you want.
**mysite/_config/extensions.yml
---
Name: mysiteextensions
After: 'framework/*','cms/*'
---
SiteConfig:
extensions:
- SiteConfigDecorator
mysite/code/extensions/SiteConfigDecorator
<?php
class SiteConfigDecorator extends DataExtension {
private static $db = array(
'FacebookURL' => 'Varchar(200)',
'TwitterURL' => 'Varchar(200)'
);
private static $has_one = array(
'FooterQuoteButtonPage' => 'SiteTree'
);
public function updateCMSFields(FieldList $fields) {
$fields->addFieldToTab('Root.SocialMedia', TextField::create('FacebookURL', 'Facebook URL'));
$fields->addFieldToTab('Root.SocialMedia', TextField::create('TwitterURL', 'Twitter URL'));
}
function __construct() {
parent::__construct();
}
}
To access these fields in the templates, you use $SiteConfig.FIELDNAME. In this case it would be $SiteConfig.FacebookURL and $SiteConfig.TwitterURL

How to set Joomla template for user/visit

I want to use specific Joomla template (with no navigation, no top and bottom) for users that connect to website through my mobile app with iframe in it. I assume that this users will start connection from specific address with tmpl param (or something similar) but is there a way to lock this template for these users?
Maybe there is some plugin to set template in session data and override default template choice?
There is a Joomla extension called Template Assigner - http://extensions.joomla.org/extension/template-assigner . It does exactly what you want.
Plugin allows me to set template only for specyfic user group, not to switch template accordingly to url but thanks to Your idea I created very simple plugin to do this, code below:
defined('_JEXEC') or die;
class plgSystemMobiler extends JPlugin
{
public function onAfterInitialise()
{
$app = JFactory::getApplication();
$jinput = $app->input;
if (isset($_REQUEST['mobile'])) $par=(int)$_REQUEST['mobile'];
if (isset($par)) $jinput->cookie->set('mobile', $par, time() + 100000, $app->get('cookie_path', '/'), $app->get('cookie_domain'), $app->isSSLConnection());
$cookie=$jinput->cookie->get('mobile');
if (intval($cookie)>0) JFactory::getApplication()->input->set('templateStyle', intval($cookie));
}
}

How to add multiple forms Joomla 2.5 component

I am developing a joomla website which required some custom component to integrate manage portfolio, user profile etc. We downloaded one of the hello_world MVC component for joomla 2.5[http://docs.joomla.org/Developing_a_Model-View-Controller_Component/2.5/Introduction] and did necessary customization. First component worked well. But now we need a new component that is having multiple forms required to integrate.
Eg: Store types for one form, store details for another form, manage country/ state by another form.
In the default component having option for manage one form [add/edit/delete/view]. Here I tried to modify/replicate but I failed.
Can anyone suggest the architecture/ sample code to manage multiple forms [Add/edit/delete/view] in joomla 2.5 component creation.
Any help will be apreciate?
Supposing You're speaking of forms stored in the model/forms folder... You should try to override the getForm() function in your model, to call the right form. You should pass a 'layout' when calling the page and then get it in the model constructor.
May be so:
class YourComponentModelYourModel extends JModelAdmin{
public function __construct($config = array()){
switch(JRequest::getVar('layout')){
case 'firstlayout' : $this->form='firstform';
break;
case 'secondlayout' : $this->form='secondform';
break;
default : $this->form='defaultform';
}
parent::__construct($config);
}
...
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_yourcomponent.'.$this->form,$this->form,
array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)){return false;}
return $form;
}
You must put a layout for each form in the views/YourView/tmpl folder and the form declaration must call the layout also :
<form action="<?php echo JRoute::_('index.php?option=com_yourcomponent&layout=firstlayout&id='.(int) $this->item->id); ?>"
method="post" name="adminForm" id="draw-form">

Why use templates in Kohana?

I don't understand the purpose of using templates in Kohana. I see almost no difference in the process of building a view with a template controller vs a regular controller, except that the template controller is tied to a given template and so is less flexible. What are the advantages?
Building view with regular controller:
Class Controller_Hello extends Controller
{
public function action_index()
{
$view = View::factory('page');
$view->page_title = 'My Hello App';
$view->content = 'hello, world!';
$view->sidebar = View::factory('parts/sidebar');
$this->response->body($view);
}
}
Building view with template controller:
Class Controller_Hello extends Controller_Template
{
public $template = 'page';
public function action_index()
{
$this->template->page_title = 'My Hello App';
$this->template->content = 'hello, world!';
$this->template->sidebar = View::factory('parts/sidebar');
}
}
Controller_Template is just an example of how you can implement your own templating-system.
It is not ready-to-use solution (at least for my projects usually). Check this one controller (it is also not ready-to-use solution but possibly it will help you understand point of extending different controllers for different purposes): http://pastie.org/2563595
I am sure there are other, maybe better solutions for templating systems. But why am I using templates in Kohana?
Think about multiple pages, all based upon one layout/design scheme. So I build a template controller using a certain view, defining layout/design, defining content, header and footer "areas". In the template controller I am loading the CSS files and script files, setting the title and meta values of the website, because every single site is using these CSS/script files with the same meta values and title.
So in every Controller extending the template controller I don't need to load the CSS/script files anew, set the meta values and title etc... But I could change all these values, maybe add a CSS file only for a single site.
Maybe all the mentioned sites have the same footer and/or header: I assign the header/footer view to the template within the template controller, so I don't need to do that in all the controller extending the template controller. Or all actions in one controller have the same header/footer, so I assignt he header and footer few in the before() function of the controller...
For me templates in kohana are a good utility for building small web applications.