Jump to content

Capturing data in ProcessWire


leftblank
 Share

Recommended Posts

Hi,

I'm new to ProcessWire after using general purpose MVC frameworks such as Laravel/Rails/Django, due to the fact I cannot find any CMS built on those platforms feels as stable, well supported, and easy to use (for clients) as ProcessWire does.

I'm trying to replicate the MVC benefits of the above frameworks in ProcessWire, so I'm abstracting my templates into Controllers and Views as described in this thread, however, I am really missing the ORM API's in these frameworks. Being able to define models and them to store relational data i.e. social data, form data, and whatever else without dropping down to raw SQL.... and then retrieving and outputting this data in my templates.

Does anybody have any advice of achieving this kind of behaviour in ProcessWire? Would it be a case of integrating a third-party ORM, or is there some whole part of ProcessWire that I've missed?

Link to comment
Share on other sites

I think Pete was right actually - the way I see it, the API, coupled with templates and fields, essentially, is your ORM :)

An ORM is just an abstraction on top of a database which makes the data easy to work with. Your database contains your tables, columns and rows of data. In ProcessWire, your rows are pages; your columns are fields, and your tables are templates (roughly!).

So to interact with those, you use the API. Relational data can be handled by using the Page reference fieldtype, for example.

Having said that, if you have a desperate need to use something other than ProcessWire to manage some data, it is just PHP. Find an ORM you like, include() it, and start using it within your site as and when you need to.

  • Like 3
Link to comment
Share on other sites

Hi, thank you for your replies! That works... having everything represented by the Page model makes sense in the context of ProcessWire, just required me to make a bit of a mental jump. 

One further question - is there anyway to exclude certain templates from the appearing in the results of the search function in the admin pages? There's hundreds of entries being returned for some data types which aren't particularly likely to be interesting to end users, who might not realise they can filter.

Link to comment
Share on other sites

Yes, you can exclude templates by filtering them on the find method

$results = $pages->find("title/body*=$query, template!=unwanted|rejected|nothingtosee");
 

or by limiting to a few templates

$results = $pages->find("title/body*=$query, template=goodone|interesting|lookhere");
 

edit: Oh, sorry, you mean in the admin. The search can be easily filtered by the search tools that appear on the side. If tht's not enough, maybe you can limit the access to some roles on the template's "access" tab, or build a custom search process.

  • Like 1
Link to comment
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
 Share

×
×
  • Create New...