0

I have created a career module and jobs can access from below url.

mysite.com/careers

This page shows list of jobs with each job shows "View More" button.

When I click on the "View More" button then open a new page and must be show that selected job full details. So this single page link like to be:-

mysite.com/careers/jobdetails/index/view/1

Here "1" means job ID.

app/code/community/Sumith/Careers/Block/Jobdetails.php

<?php   
class Sumith_Careers_Block_Jobdetails extends Mage_Core_Block_Template
{   
    public function __construct()
    {
        parent::__construct();
        $datasets=Mage::getModel('careers/jobdetails')->getCollection()->addAttributeToSort('sh_job_details_id', 'DESC');//->addAttributeToSelect('*');

        $this->setDatasets($datasets);
    }

    protected function _prepareLayout()
    {
        parent::_prepareLayout();
        $pager = $this->getLayout()->createBlock('page/html_pager')->setCollection($this->getDatasets());
        $this->setChild('pager', $pager);
        $this->getDatasets()->load();
        return $this;
    }

    public function getPagerHtml()
    {
        return $this->getChildHtml('pager');
    } 
} // end of the class

app/code/community/Sumith/Careers/controllers/JobdetailsController.php

<?php
class Sumith_Careers_JobdetailsController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        $this->loadLayout();   
        $this->getLayout()->getBlock("head")->setTitle($this->__("Job Details"));

        $breadcrumbs = $this->getLayout()->getBlock("breadcrumbs");

        $breadcrumbs->addCrumb("home", array(
            "label" => $this->__("Home Page"),
            "title" => $this->__("Home Page"),
            "link"  => Mage::getBaseUrl()
        ));

        $breadcrumbs->addCrumb("careers", array(
            "label" => $this->__("Job Details"),
            "title" => $this->__("Job Details")
        ));

        $this->renderLayout(); 
    }
} // end controller class

I'm using magento 1.9 version.

If anyone can help me to fix this appreciate that.

  • What is the issue that you are facing ... ? and code of what have you tried – Vishwas Bhatnagar Aug 4 '17 at 6:22
  • mysite.com/careers/jobdetails/index/view/1 link is working. I want to show ID=1 job details on this new page. – Sumith Harshan Aug 4 '17 at 6:32
1

With your URL mysite.com/careers/jobdetails/index/view/1 view will be the parameter name and the value for this parameter will be 1

Now to get this parameter value in your controller action function, you can use below code

$careerId = $this->getRequest()->getParam("view");

Now you can use this $careerId to load your model and get details for the carrer.

  • Do you know how to load job details from view/1 page path ? I just want to know now how to call from same jobdetails controller and block file. – Sumith Harshan Aug 4 '17 at 11:37
  • To provide you any solution, it will require your current career module code which you are using. Please add the relevant controller, block, model, config, layout and template files to code to check. @SumithHarshan – Jaimin Sutariya Aug 4 '17 at 11:42
  • I just added the code above. – Sumith Harshan Aug 4 '17 at 11:42
  • Any solutions "Jaimin Sutariya" ? – Sumith Harshan Aug 9 '17 at 5:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.