Comments (5)
Well, there's a few ways you could go about that. One - if you are feeling adventurous on your home page is to dig into backbone and do some model binding for those recent posts via ajax. If you are not really concerned with it being fancy like that, you can just do it the old fashioned way, for example:
Inside DefaultController->Home you need to do a database read and then assign the results to the template like so:
$criteria = new PostCriteria();
$criteria->SetOrder('CreatedDate', true); // <- sort descending by created day
$posts = $this->Phreezer->Query('Post',$criteria)->GetDataPage(1,5)->ToObjectArray(); // <- get only 5 records
$this->Assign('posts',$posts);
Then inside ViewDefaultHome.tpl you would loop through them to display. That code will be slightly different depending on whether you're using Smarty or Savant. Here would be the smarty code:
{foreach from=$posts item=post}
<div>{$post->CreatedDate|escape} by {$post->Author|escape} : {$post->Title|escape}</div>
{/foreach}
Savant is just regular PHP code and would look something like this:
<? foreach ($posts as $post) {
echo '<div>' ;
$this->eprint($post->CreatedDate . ' by ' . $post->Author . ' : ' . $post->Title); // using eprint to prevent css exploits
echo '</div>';
}?>
from phreeze.
I will dive into the adventure. I want to take full advantage of Phreeze, so because its Javascript MVC on top of Savant MVC, I need to stick with models.
from phreeze.
cool. It's mainly going to be javascript/backbone code in that case. The Phreeze REST API is already set up and ready for you to read the data.
Learning backbone/underscore takes a bit of time and you definitely will want to get familiar with their support documentation. It took me about a week to really get comfortable with it. But once you figure it out it will be very liberating and you'll probably have a greater understanding of what Phreeze really is, and how the generated code is in many cases just a suggestion of how you should build things.
I feel like the Javascript that Phreeze generates is pretty decent but not 100% perfect and I'm waiting for somebody to come along with a deep understanding of backbone to help clean it up!
from phreeze.
There are alternatives to Phreeze, like the yii framework. I haven't tested it out fully, but after 12 hours I really got frustrated with it. Phreeze feels cleaner, intuitive, easier to setup and smarter, but, more important Phreeze implements backbone. This is a real big plus. Just imagine doing this afterwards :p It would take me ages.
So I'll start working on the documentation and see how backbone works and such, now that I have the authentication
in place.
from phreeze.
For everybody who is reading this:
<?php foreach ($this->posts as $post => $val): ?>
<?php echo $this->eprint($val->Title); ?><br/>
<?php endforeach; ?>
Would get you the parsed data.
from phreeze.
Related Issues (20)
- Greetings HOT 1
- Error after building
- Its work wordpress 4.8+?
- Phreeze Builder Broken HOT 1
- master-detail / master-detail-detail examples
- builder/analyze gives 404 on Nginx
- Generated code in scripts/model.js displays all tables regardless
- index null HOT 1
- Controler filename / classname containing space character(s)
- Stuck loading tables with varbinary?
- Error Opening MySQL Database HOT 1
- analyze Not Found HOT 1
- after instalation HOT 2
- Undefined offset: 1 in DBTable.php at line 285 HOT 1
- Jason Hinkle 1970-2016 HOT 5
- Security issue : use hash_equals() instead of '===' to compare hashes
- Show on select many-to-one
- http://192.168.32.10/phreeze/builder/analyze HOT 1
- Foreign key issue
- Problem after builder page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phreeze.