<p>To fetch an entry from your module and pass it to a template you can do:</p>

<pre><code>$entry = \craft\elements\Entry::find()-&gt;one();
return \Craft::$app-&gt;getView()-&gt;renderTemplate('path/to/template', ['entry' =&gt; $entry]);
</code></pre>

<p>Then in your template, you will have access to an <code>entry</code> variable.</p>

CC BY-SA 4.0
2020-01-09T15:18:32.283Z
2020-01-09T15:18:32.283Z
Oli
<p>I am building a module to show a job/vacancy-list and the detailpage of a job, the data is fetched from a remote json feed.</p>

<p>Currently I have the following routes to a controller in my module</p>

<pre><code>return [
  'job' =&gt; 'job-offers-module/job/process',
  'job/detail' =&gt; 'job-offers-module/job/detail',
];
</code></pre>

<p>And loading twig templates eg.</p>

<pre><code>namespace modules\joboffersmodule\controllers;

use Craft;
use craft\web\Controller;
use craft\web\View;

class JobController extends Controller
{
  protected $allowAnonymous = true;

  public function actionProcess(){
    return \Craft::$app-&gt;view-&gt;renderTemplate('joblist');
  }
  public function actionDetail(){
    return \Craft::$app-&gt;view-&gt;renderTemplate('jobdetail');
  }
}
</code></pre>

<p>But I keep getting an error that the <em>entry can not be found</em>... Do I need to register the paths in the module as a handle?</p>

<p>How can I load an entry from my within the module and pass it to the templates?</p>

CC BY-SA 4.0
2020-01-09T13:55:22.687Z
Does not answer your question, but you could consider to use feed me pro for that.
Max Strebel
<templating><craft3><modules>
How do I render pages with dynamic content from a json feed
# How do I render pages with dynamic content from a json feed

(Asked by: username_0 on 2020-01-09)

I am building a module to show a job/vacancy-list and the detailpage of a job, the data is fetched from a remote json feed.
Currently I have the following routes to a controller in my module
return [
  'job' => 'job-offers-module/job/process',
  'job/detail' => 'job-offers-module/job/detail',
];

And loading twig templates eg.
namespace modules\joboffersmodule\controllers;

use Craft;
use craft\web\Controller;
use craft\web\View;

class JobController extends Controller
{
  protected $allowAnonymous = true;

  public function actionProcess(){
    return \Craft::$app->view->renderTemplate('joblist');
  }
  public function actionDetail(){
    return \Craft::$app->view->renderTemplate('jobdetail');
  }
}

But I keep getting an error that the entry can not be found... Do I need to register the paths in the module as a handle?
How can I load an entry from my within the module and pass it to the templates?

**Tags:** templating, craft3, modules
> **Comments:**
> **username_1**: Does not answer your question, but you could consider to use feed me pro for that.  

---

## 1 answers

### Answer by username_2 on 2020-01-09. Score: 1 | Accepted answer

To fetch an entry from your module and pass it to a template you can do:
$entry = \craft\elements\Entry::find()->one();
return \Craft::$app->getView()->renderTemplate('path/to/template', ['entry' => $entry]);

Then in your template, you will have access to an entry variable.


---

