First component creation based on HelloWorld failed - joomla

I'm trying to create my first component for Joomla 2.5 but when try to execute get this error:
Error: 500
You may not be able to visit this page because of:
an out-of-date bookmark/favourite
a search engine that has an out-of-date listing for this site
a mistyped address
you have no access to this page
The requested resource was not found.
An error has occurred while processing your request.
View not found [name, type, prefix]: transportation, html, transportationView
What I've developed now is very basic and this is the controller under site/components/com_transportation/controllers/controller.php
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla controller library
jimport('joomla.application.component.controller');
class TransportationController extends JController {
}
And under site/components/com_transportation/views/view.html.php this:
<?php
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// import Joomla view library
jimport('joomla.application.component.view');
class TransportationViewTransportation extends JView {
// Overwriting JView display method
function display($tpl = null) {
// Assign data to the view
$this->msg = 'Hello World';
// Display the view
parent::display($tpl);
}
}
What I'm missing? What is wrong?

Your folder structure is incorrect. Your view file must be in site/components/com_transportation/views/transportation/view.html.php

Try this ,
When you start developing a new component go through the tutorial deeply,Then start modifying the samples .
follow this url it will help you .Its for 1.5 but the things are same for 2.5.
Only you have to mention version in the xml
<install type="component" version="1.5.0">
Also you will get a sample component download from this.
Download it and compare with your component then find the issue.
Hope this may helps..

View not found [name, type, prefix]: transportation, html, transportationView
Means just tha no view was found with the class name of transporationViewtransporation and the type view.html.php. What is the name of the class in your view.html.php file? is the second transportation really lower case like that? Also what are the name(s) of your layout and xml files in the tmpl folder?

Related

Joomla MVC Module delete model

I'm a newbie on Joomla developing and I'm trying to fix an old administration module made by 'someone before me'. Module's been developed using MVC Components, it has several CRUDs and I'm stucked at deleting an item. The template view adds the toolbar icon like this:
JToolbarHelper::deleteList('', 'paises.delete', JTOOLBAR_DELETE);
It also has at the list controller (DistribuidoresControllerPaises), the getModel function:
public function getModel($name = 'Pais', $prefix = 'DistribuidoresModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
The model class:
class DistribuidoresModelPais extends JModelAdmin
When selecting an item on the list, and clicking the trash button an empty page opens with this ending:
administrator/index.php?option=com_distribuidores&view=pais
If I come back to grid, the item still remains.
Any suggestion?
Thanks in advance
You can debug this by enabling debugging from Joomla configuration or you can try to to check with exit with in "delete" function of "paises" controller and can check you get item ids in post request or not.
Also you are using view "pais" also using model "pais" then why you are using "paises" controller for delete function, you should use "pais" controller to delete.
Also provide delete function which you are using to delete items, it may contain some issue.

php codeigniter uploading photos

So I was watching a video on how to upload photos using codeigniter. The link I used is here and the code is also at this site http://code.tutsplus.com/tutorials/codeigniter-from-scratch-file-uploading-and-image-manipulation--net-9452. I got everything to work however, when I tried to use the code on my own website I ran into a problem.
Basically all I changed was that I created a template for the view to be loaded in instead of just loading a single view. There is a controller Gallery.php file that looks like the follows.
<?php
class Gallery extends CI_Controller {
function index() {
$this->load->model('Gallery_model');
if ($this->input->post('upload')) {
$this->Gallery_model->do_upload();
}
$data['images'] = $this->Gallery_model->get_images();
$this->load->view('gallery_view',$data);
}
}
I simply changed this code to. Really only changing the last line and replacing it with those new three bottom lines.
<?php
class Gallery extends CI_Controller {
function index() {
$this->load->model('Gallery_model');
if ($this->input->post('upload')) {
$this->Gallery_model->do_upload();
}
$data['images'] = $this->Gallery_model->get_images();
$var = $this->load->view('gallery_view',$data,true);
$data['center_content'] = $var;
$this->load->view('includes_main/template',$data);
}
}
Now I get an strange error that I do not understand and no error shows up in the console log. Here is a picture of the error. http://i.imgur.com/tsKNj9W.png. The error says "unable to load the requested file" then doesn't have any file name after it. then there is a .php at the bottom of the page. I just don't have a clue what is giving me this error. I checked my template over again and again, but don't see anything wrong.
My template is as follows. I commented out everything just to make sure nothing else was giving me this error. So I am just left with one line.
<?php $this->load->view($center_content); ?>
Thanks for reading. Sorry I just have been stuck on this for a while and still haven't been able to fix it.
In this case there there are many mistakes. you did not load upload library and you also did not set config array. you can find on codeigniter user guide how to upload a file. I recommend to you read this link to upload a file in codeigniter
https://ellislab.com/codeigniter/user-guide/libraries/file_uploading.html

Magento, checkout/cart block not loading in ajax extension

I'm programming an ajax extension to Magento and I'm having trouble when I try to make checkout/cart work with it.
I want to reload the entire block, including the item and also the cart totals after a change in any product in the cart.
I've modified the layout as many sites said and I can't get the checkout/cart block render well.
My two solutions were:
1° Tryed to update the layout via an xml file, and I get a false in $block_cart.
I've a class
Mati_Ajax_CartController extends Mage_Checkout_CartController
{
...
public function updateShoppingCartAction()
{
...
$block_cart = $this->getLayout()->getBlock('checkout/cart');
...
}
}
and a xml file (which I'm sure i'ts being loaded beacause the js pointed there is loading)
<checkout_cart_updateshoppingcart>
<update handle="checkout_cart_index" />
</checkout_cart_updateshoppingcart>
2° Tryed to create the block
public function updateShoppingCartAction()
{
...
$block_cart = $this->getLayout()->getBlockSingleton('checkout/cart')->setTemplate("checkout/cart.phtml")->toHtml();
...
}
And here I get the block, but when the template executes $this->getChildHtml('totals');
It gets a false anwer, so the webpage has some differences with the previousone
Does anybody knows how to make this work ?
In your first attempt just append ->toHtml();
Alternatively you could have included that as a command in the xml output="toHtml"
Check how the checkout/onepage/review functions if you are looking for advice.
There they access the response object and then set the body of the response to the html variable, in your case $block_cart
The key was in the xml file
<ajax_cart_updateshoppingcart>
<update handle="checkout_cart_index" />
</ajax_cart_updateshoppingcart>

CodeIgniter - Including sections of code?

I have about 9 lines of code that will be the same in many of my controllers. They go in the index and are used to check whether the user is logged in, what level of access has been granted, and grab some session variables. What's the best way to include snippets of code that are not complete functions within themselves?
The snippets are not in all controllers, just the ones that build the admin section of the application.
It would be great if I could use one line of code to include the snippet but I'm new to CodeIgniter and I don't want to stray from best practices. If you could include a brief example that would help me visualize this. Thanks!
You want to create an extension of the base CI controller and do your checks there. Extending the cores are in the documentation here: http://ellislab.com/codeigniter/user_guide/general/creating_libraries.html Scroll down to the Extending Native Libraries part.
In your new controller you can do something like this:
<?PHP
class MY_Controller extends CI_Controller
{
function __construct()
{
parent::__construct(); //Gets all the CI_Controller functions and makes them available to this controller.
if($this->session->userdata('is_logged_in')
{
$this->load->model('categories');
$this->categories=$this->categories->getAllCategories();
}
}
}
Then in your other controllers you use MY_Controller instead of CI_Controller like this:
<?php
class Pages extends MY_Controller {
Obviously you'll have your own checks and variables to load but this should give you the general idea. In the example above I can now use $this->categories to retrieve my categories anywhere in the application that's been loaded with MY_Controller.
I'm using a 'main' template file (views/template.php):
// views/template.php
<?php $this->load->view('includes/header'); ?>
<?php $this->load->view('includes/' . $main_content); ?>
<?php $this->load->view('includes/sidebar'); ?>
<?php $this->load->view('includes/footer'); ?>
So the view directory structure is something like this:
--views
--includes
- header.php
- footer.php
- template.php
As you can see inside the view/includes/ folder I'm using some reuseable snippets like 'header.php', 'footer.php'...
So inside a controller I'm loading this main template file:
class MyController extends CI_Controller {
public function index()
{
//...
$this->load->view('template',$data);
}
}
So it loads 'template.php'.
And can use the $data inside header.php, footer.php too..
But you can vary this as you want, it's just a 'basic' idea..

Where is Itemid used to flag active menu item in Joomla 2.5.6?

Can anyone please help me with the process flow through which the Joomla Itemid parameter ends up being the highlighted menu item?
I have embedded a 3rd party application in Joomla and by temporarily changing the php environment within the application.
I am able to get joomla html and insert the 3rd party html by replacing a token.
Simplified Code:
if ($_SERVER['REQUEST_METHOD'] == 'GET' ) {
$_SERVER['REQUEST_METHOD'] = '';
}
$_SERVER['REQUEST_URI'] = '/joomla/index.php?view=mycom&option=com_mycom&Itemid=103';
$_SERVER['SCRIPT_NAME'] = $_SERVER['PHP_SELF'] = '/joomla/index.php';
$_SERVER['QUERY_STRING'] = 'view=mycom&option=com_mycom&Itemid=103';
ob_start();
require_once '/joomla/index.php';
$joomlaHTML = ob_get_clean();
echo str_replace($replacementToken, $thirdPartyHTML, $joomlaHTML);
In v1.5.x, the menu item with ID 103 is properly highlighted but in v2.5.6, it isn't and the Home item is always highlighted. I think it used to be highlighted correctly in v1.6.x and earlier versions of 2.5.x as well but not sure.
I wanted to find how the process flows (where this is set) so I can see what tweaks I need to make.
DELETED WRONG INFO
Thanks Dayo! you saved my day with this:
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
I don't fully understand the breadcrumb part, but I managed to get it working by editing my component's controller.php to read:
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
// force highlight the external url menu item
$Itemid = JRequest::getVar('Itemid');
$menu = JSite::getMenu();
$menu->setActive($Itemid);
// force fix the breadcrumb
$app = JFactory::getApplication('site');
$pathway =& $app->getPathway();
$bcrumbs = &JPathway::getInstance('site');
// import Joomla controller library
jimport('joomla.application.component.controller');
/**
* MyCom Component Controller
*/
class MyComController extends JController
{
}
Look in the following File
Check the
/modules/mod_menu/mod_menu.php
File and you will see two functions has been called "getActive" and "getDefault"
Which can be find in following file
/libraries/joomla/application/menu.php
I think it can be customized easily now

Resources