dont find the view in joomla - joomla

Hi everyone I am using joomla 2.5 for a website
I create a component to insert products in the data base in the back-end, and I want to show this product in front-end
I have this link in the view to show a products with type=1;
<div class="col2">Productos</div>
In the front-end of the component controller.php I have this
class HardwareController extends JController
function integrados(){
$model = &$this->getModel(JRequest::getCmd('view'));
$view = &$this->getView(JRequest::getCmd('view'), 'html');
$view->setModel($model, true);
$view->hardwareIntegrado();
}
in my model I have
class HardwareModelHardwares extends JModelList
function getIntegrados(){
$db=& JFactory::getDBO();
$query= "SELECT *
FROM ".$db->nameQuote('#__hardware')."
WHERE ".$db->nameQuote('tipo')."=".$db->quote("1").";";
$db->setQuery( $query);
$restaurantes=$db->loadObjectList();
JRequest::setVar('hard', $restaurantes);
return $restaurantes;
}
and in my view.html.php I have this
public function hardwareIntegrado(){
$this->assignRef('pagination', $this->get('pagination'));
$this->assignRef('hardware', $this->get('integrados'));
$this->assignRef('list', $this->get('list'));
parent::display();
}
When I click to the link I obtain this error
500 - View not found [name, type, prefix]: hardware, html, hardwareView
any idea!

You should change your view class to hardwareViewHardware

You are getting this error-
500 - View not found [name, type, prefix]: hardware, html, hardwareView
because it's looking for hardware view.In the link- index.php/hardware/integrados it seems you are passing view=hardware . Whereas everywhere you have defined it as hardwares like in folder name and class.Either change link or class and folder.
Hope this will help.

Related

how to display record by id in codeigniter

I wanto to display blog detail from database by clicking on specific blog item.I have created a controller and modal for that but no idea hot o display data by id in detail page.
Controller-
function blogContent(){
$data['info'] = $this->auth_model->blogDetails($id);
$popular['popular'] = $this->auth_model->getPopularcourses();
$this->load->view('nulearnFront/blog_details', $data);
$this->load->view('nulearnFront/header', $data);
$this->load->view('nulearnFront/footer', $popular);
}
Modal-
public function blogDetails($id) {
$q = $this->db->select('*')->from('blog')->where('id',$id)->get();
return $q->result();
}
but i've no idea how to display data by id on frontend. please check the above code also.
You can add a route for the controller in the config/routes.php file like this:
$route['blog/(:any)'] = 'controller/blogContent/$1';
and modified controller
function blogContent($id){
$data['info'] = $this->auth_model->blogDetails($id);
$popular['popular'] = $this->auth_model->getPopularcourses();
$this->load->view('nulearnFront/blog_details', $data);
$this->load->view('nulearnFront/header', $data);
$this->load->view('nulearnFront/footer', $popular);
}
after that, you should only create a correct link to a blog, like this:
My Blog
and you should get blog id in your controller

magento get custom attribute label

I've a problem, I want to show the label of a custom attribute in the product page.
I explain me better, starting from this link because is what I want to do:
http://www.customy.com/blog/how-to-display-video-on-magento-product-page/
I want a video product in the sidebar of the product page, so I create a new custompage.phtml and i put this in the sidebar from catalog.xml, in my custompage.phtml I put this code to have the custom label:
getResource()->getAttribute('video')->getStoreLabel();?>
but I have this error:
"Fatal error: Call to a member function getResource() on a non-object in ..path//"
I have try different code but still have this problem.
I think that I forget to put something in my .phtml but I'm new of Magento and I don't know what!
Thank in advance!
Since $_product didn't work then you'll need to load the object before attempting to access the attribute. Try this:
$product_id = Mage::registry('current_product')->getId();
$_product=Mage::getModel('catalog/product')->load($product_id);
echo $_product->getResource()->getAttribute('video')->getStoreLabel();
If you don't have access to the product model, I wrote a small query to get it from DB. This could be done better, but should be a decent starting point for your class:
protected $_dbConn;
public function __construct()
{
$this->_dbConn = Mage::getSingleton('core/resource')->getConnection('core_read');
}
public function getAttributeLabel($code)
{
$query = "
SELECT b.value
FROM eav_attribute a
JOIN eav_attribute_label b
ON a.attribute_id = b.attribute_id
WHERE a.attribute_code = '".$code."'";
return $this->_dbConn->fetchOne($query);
}

Laravel Trying to get property of non-object but not sure why

I want to grab some data from a database and display on a layout page, I've basically started building a small CMS to get into Laravel and all has gone fine so far but now i'm at a wall, and can't find a solution.
I have a layout blade file like so: http://paste.laravel.com/1fB1 nothing majot but you will see i have used $page->meta_title etc in there and in my controller i have:
public function home()
{
$pages = Pages::all();
return View::make('frontend/home')->with('pages',$pages);
}
Which I have a pages model doing nothing else really like so:
class Pages extends Eloquent {
protected $table = 'pages';
}
So why is it trying to get property of non-object and I don't really want to use a foreach because this is going to be the frontend of my 'test' website so a foreach wouldn't suite.
You'll need to access these items as a multi-dimensional array if you don't want to loop through them.
$pages[0]['field_name_here']
or
$pages[1]['field_name_here']
Its a bit of a tough one to answer without knowing how you want your CMS to work.
For example, you could have a route as {pagename} in your routes.php file, then have a page controller where you would get the requested route from the variable passed in. This would then load the page you wanted using the variable
public function page( $pagename ) {
$page = Page::where('page_title', '=', $pagename)->first();
View::make('frontend/page', array( 'page' => $page ));
}
Using a route like that, and the controller, in your view you could use {{ $page->content }} to get the content of the requested page from the database and display it.
Hope this helps.
Edit: Example Route:
Route::get('{pagename}', 'PageController#page');

Joomla problem with MVC component

I have problem with Joomla layouts in my component..There must be something bad with file/class name convention..
I was trying to ask on Joomla developer forum, but noone answered..
So I am getting this error.. 500 - View not found [name, type, prefix]: PostToBank,,postToBankView
The view is in views/postTobank/view.php and name is postToBankViewPostToBank
In my controllers/controller.php file I have class named PaymentController which contains this part of code.
$view = $this->getView('PostToBank','','postToBankView');
$this->getModel("Payment")->savePaymentData($data);
foreach ($data as $key => $value) {
$view->assignRef($key, $value);
}
$view->setLayout('postTobank');
$view->display();
my view.php file looks like this
class postToBankViewPostToBank extends JView{
function display($tpl=null){
//display set template
parent::display($tpl);
}
}
on attached image is full folder structure of my component..
Please whats wrong with this?Thanks
Joomla uses a naming conventions and you are not following them. Refer to http://docs.joomla.org/File_Structure_and_Naming_Conventions
Also, your views should be view.html.php and then you do not need to call setView.
FYI: this is where the error is coming from. Refer to this: http://docs.joomla.org/API16:JController/getView, even though it is 1.6 doc it is same in 1.5
Look though this tutorial and adopt regular conventions: http://docs.joomla.org/Developing_a_Model-View-Controller_Component_-_Part_1

Codeigniter reusable sections

I have a table of data from a database that I want to display on various pages of my website. Ideally, i would like to just have an include or something that will go off and get the data, and return the html table. The html and data will be identical everytime I need to use this.
I wanted to know the best way of doing this
Thanks
EDIT
If this helps, something similar to a Django "inclusion" custom tag...for any django developers reading
you need to pass the variable $data to the view method.
This is your code:
function load_my_view(){
$this->load->model('my_table');
$data['my_results'] = $this->my_table->my_data();
$this->load->view('my_view');
}
Please change it to this in order to load the $data into the view:
function load_my_view(){
$this->load->model('my_table');
$data['my_results'] = $this->my_table->my_data();
$this->load->view('my_view',$data);
}
You should use a function in a model to fetch the data you need. Your controller calls the model function and sends the returned information to a view. You don't need to use traditional php includes with Codeigniter. I recommend a review of the user guide. It's very good and will tell you all the basic stuff you need to know to develop with CI. But to get you started, you watn to use Models, Views, and Controllers. Your url will tell CI what controller and function inside that controller to run. If your url is
http://www.example.com/my_controller/load_my_view
Then CI will do what is inside the load_my_view function in the my_controller controller. function load_my_view in turn instantiates a model "my_table" and runs a database query, returns information that the controller sends to the view. A basic example follows:
Your model
class my_table extends CI_Model{
function my_data(){
$this->db->select('column_1,column_2,column_3');
$this->db->from('my_table');
$query = $this->db->get();
if($query->num_rows()>0){
$result = $query->result();
}
else{
$result = false;
}
return $result;
}
}
Your controller
class my_controller extends CI_Controller{
function load_my_view(){
$this->load->model('my_table');
$data['my_results'] = $this->my_table->my_data();
$this->load->view('my_view');
}
}
Your View
<ul id = "my_db_results">
<?php foreach($my_results as $result):?>
<li><?php echo $result->column_1." : ".$result->column_2." ( ".$result->column_3." )";?></li>
<?php endforeach;?>
</ul>
It looks like a good oportunity to use cache: http://codeigniter.com/user_guide/libraries/caching.html
Ok, so here is one thing that worked for me, but its definitely not perfect.
I created a view in which made a call to the model getting the data then put the data into a table. This way, I only have to include this view to put the table anywhere.
I understand this completely ruins the point of having a MVC framework, but hopefully it demonstrates what I want to do...and it works

Resources