Sign in to follow this  
rareyush

page reference field

Recommended Posts

I added a field type 'page reference' using checkboxes knows as services.

now i want to display the pages according to service.

I can display all services list but when i click on any services then I can see whole code of site 

 

any idea where i am wrong

?

main 
	cate1
		subcate1
		subcate2
	cate2
		subcate1
		subcate2
services
	first-service
	second services

	

 

 

these services is being used as a page reference  in subcate1, subcate2 templates.

 

and in the navbar when i click on services and then when i click on any of the following service then i can see whole source code of my site.

Share this post


Link to post
Share on other sites
42 minutes ago, neosin said:

can you post  template code?

subcate template code

<?php namespace ProcessWire;


 $ser="";
$title= $page->title;
$services = $page->get('services');
$brief= $page->brief;
  
  if($page->services) {
 foreach($page->services as $p) {
   $ser.= "<br><p>{$p->title}</p>";
 }
}

echo "
<div style='margin-top: 100px;'>
$title <br>
$ser
</div>
";
?>

 

Share this post


Link to post
Share on other sites

it's fixed

I mistakenly selected this in files tab in services template

rjVNHRn.png

 

still anyone knows how to show subcate pages using services???

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By benbyf
      Hello, having trouble getting PW to save my user or field in cron hook.
      It seems to report the same field info each time unchanged. It should be counting down in seconds.
      public function init() { // set to every30Seconds in settings $this->defaultInterval = $this->cron_check; // add hooks to CRON $this->addHookAfter("LazyCron::{$this->defaultInterval}", $this, 'checkUserSubscription'); } public function ___checkUserSubscription(HookEvent $e){ // seconds since last lazycron $seconds = $e->arguments[0]; $log = wire('log'); $field = $this->exclusiveRole; // users with specific role and field $users = $this->users->find("roles=$field"); foreach ($users as $user) { // get stored time $currentTime = $user->get($this->fieldName); // if time not null if($currentTime){ // evalute stored time minus time past $resultTime = intval($currentTime) - intval($seconds); $log->message("result ".$resultTime); // save user page $user->set($this->fieldName, $resultTime); $this->users->save($user); } } }  
    • By rareyush
      I am trying too create a custom field where when user select to create a category 2 text area shows where one title of the category goes & another for some content.
      Like in a picture I want 2 text areas when I click on create new

    • By MilenKo
      Hello all.
      A few days ago I decided to redo my first PW theme (knowledge sharing one) trying to apply some more elegant logic and most important - to learn to filter page results by a Page reference field with some values. So far it is all going well except the fact that I am now at a stage to add some page parameters and am a bit stuck as to how to filter them.
      Here is an example of the structure planned to use:
      !-- Articles (template = articles.php)
      !---- Article 1 (template = articles-inner.php)
      !---- Article 2 ..
      !---- Article 3 ..
      !-- Categories (no template file)
      !---- Category1 (same template as  parent)
      !---- Category2 ..
      !---- Category3 ..
      !-- OS (no template file)
      !---- Windows (same template as parent)
      !---- Linux
      !---- MacOS
      So far the home page and articles-inner pages are fully working. I need to show in the sidebar two blocks; Categories, OS where clicking on one would show only the posts containing the PageReference field value. To list the categories and OS in the block won't be a problem as I would just need to query the parent and list all the children (if any) with the proper markup. However, how to have the Categories and OS blocks link only to the specific posts that is the issue. In my previous version of the knowledge profile, I had the "categories" listed as a parent and the posts matching the category were just children of it. But now my goal is to learn how to add different parameters using Page Reference and have a way to show the results per the specific value.
      How would you organize a similar structure and what approach to take to have a simple and elegant solution?
      Or, if you know of a PW profile that I could dissect and learn the filtering mechanism of Page Reference etc. it would be even better. I am presently looking at the Ghost profile however Wire-approach is still not very much clear to me, unfortunately.
       
    • By theo
      Here is my first processwire module (beta).
      https://github.com/theo222/ImagePickerField
      A lot of "first times". First time Github, Markdown and of course PW Modules.
      So be gentle please.
      I hope it works.

    • By hezmann
      I have the following page structure
      Continents Countries Regions I then have pages "walks" which has a multi-select Page Reference field Regions (I've tried using dynamic fields for this but it wasn't accomplishing what I needed) which has the regions listed by country and then the region (continent is more for searching later on so doesn't need to be seen here).
      I'm trying to get a count of firstly all the walks within a continent, then country, then region but can't seem to figure out the selector for this.  
      Thanks,
      Heather