Php + codeigniter + framework7

i am using php and codeigniter.

This is App controller

// when you type url like '/app', you come here
public function index(){ 
	$this->appList();
}

This is my Controller and index function

This is function appList() in controller.

$this->load->view('home/app/v2/includes/header', $header);
$this->load->view('home/app/v2/pages/loading',$myData);
$this->load->view('home/app/v2/includes/footer',$footer);

this is loading.php.

<div class="view view-main">
  <div data-name="home" class="page">
    loading...
  </div>
</div>

In app.js( loaded in the footer.php)
i wrote like this.
스크린샷 2020-03-24 오후 6.38.46

i cannot get data from async.

so we redirect ‘/app’ like below

var mainView = app.views.create('.view-main',{
  reloadPages: true,
  allowDuplicateUrls: true,
  // unloadTabContent : false,
});
mainView.router.navigate('/app', {
  ignoreCache  : true,
  reloadCurrent : true
});

then we can get data from async.

But,
when i try to use ‘Views as Tabs’ (https://framework7.io/docs/tabs.html#views-as-tabs),
all html goes into <div class=view view-main"> we made in loading.php(view)

This is main.php(view)

<div id="view-home" class="view view-main tab tab-active">
     ...
 </div>
 <!-- Catalog View -->
 <div id="view-catalog" class="view tab">
        ...
 </div>
 <!-- Settings View -->
 <div id="view-settings" class="view tab">
        ...
 </div>

(result)

<div class="view view-main">
     <div id="view-home" class="view view-main tab tab-active">
        ...
      </div>
      <!-- Catalog View -->
      <div id="view-catalog" class="view tab">
        ...
      </div>
      <!-- Settings View -->
      <div id="view-settings" class="view tab">
        ...
      </div>
</div>

but we want like below
(the html we want)

<div class="view view-main">
</div>
<div id="view-home" class="view view-main tab tab-active">
        ...
</div>
<!-- Catalog View -->
<div id="view-catalog" class="view tab">
        ...
 </div>
 <!-- Settings View -->
<div id="view-settings" class="view tab">
        ...
</div>

can i use php with framework7?
please help T.T
Thank you everyone~~~

Hey, have you had a fix yet? I am also trying to work with this (codeigniter 4 + framework7) but no luck. Any type of help would be appreciated.

If I am not mistaken I think you didn’t understand the concept of a PWA.

The idea is that the server doesn’t render the client, which is usually the case with PHP or php frameworks.

So how do PWA usually work. The browser of a client or in case of cordova/phonegap/electron/ionic apps, the Smartphone does all the UI rendering and the backend or the server only provides data

so how could this work with codeigniter?

Codeigniter would have to return data in json format so that the client can work with it.
The controller function could look like that:

//controller function

public function signin() {
    $arr = array('a' => 1, 'b' => 2, 'c' => 3, 'd' => 4, 'e' => 5);    

   //add the header here
    header('Content-Type: application/json');
    echo json_encode( $arr );
}

and in the front end you would have to make an ajax request to get the data.

1 Like