Jump to content

Few noob questions


jukooz
 Share

Recommended Posts

Hello,

I found ProcessWire today when exploring ModX little bit. It's absolutely amazing.

I have few questions and I must state that I don't have php skills, but PW seems simple enough to implement without these skills.

1. What is the best way to "split" code for better templating? I mean writing head section only once, footer only once etc. I realize that it may be done in many "good" ways, but how would you prefer it being done? Can they be seperate templates so that I could create reusable building blocks?

2. Can I have "global variables" that I would use in templates but don't want to create separate template or page for?

3. How do you differentiate pages when you have 2 menus on website (how to create page added to second menu only)? How 2 menus play with the tree?

I will ask more noob questions soon ;)

  • Like 1
Link to comment
Share on other sites

Hi, jukooz and welcome.

1) For simple websites you could use usual includes to reuse your building blocks. See the home.php and basic-page.php for the example in site/templates/ folder. Also see this really cool thread about different approaches to templating.

2) You could create a page using a special template with all the necessary fields to store your global variables. Then you could access it everywhere in your template them as easy as:

$globalVars = $pages->get("/path/to/your/page/"); // you can also use page id instead of url
$globalVars->fieldname;

You could include it in your header.inc so that you don't have to call it every time.

3) You could use a "show (hide) in secondary menu" checkbox for your pages and then check against its value in your code to show only items you need.

Have you seen this already?

  • Like 2
Link to comment
Share on other sites

Thanks. Very interesting thread about templating. I must learn php little bit - ProcessWire actually encourages me to do so :)

Could you show me example code for 2 separate menus?

I will try ProcessWire on weekend, don't have enough time now, but how it treats not filled fields in pages? Are there some options regarding that - optional/mandatory fields?

Is there possibility to set thumbnails to be resized whole pictures (not only part of it that have to be adapted every time)?

How hard it would be to move website to another hosting and another domain? What is the process? Is there some kind of import/export?

Thanks again and sorry for my english,

jukooz

Link to comment
Share on other sites

I will try ProcessWire on weekend, don't have enough time now, but how it treats not filled fields in pages? Are there some options regarding that - optional/mandatory fields?

It depends on the fieldtype. Though for most fieldtypes, values are optional. But in order to create a page from the admin or the API, it must have either a name or a title. If no name is supplied from the API, PW will try to create one from the title.

Is there possibility to set thumbnails to be resized whole pictures (not only part of it that have to be adapted every time)?

Yes, you can choose to specify only the width or only the height, and the other dimension will resize proportionally. If both width and height are specified then it will crop as needed to reach your target dimension, and it will never stretch a photo non-proportionally.

How hard it would be to move website to another hosting and another domain? What is the process? Is there some kind of import/export?

It's pretty much the same as with any other web site where you copy the files and database. However, PW does have a Profile Export module that lets you create a site profile that can be imported elsewhere. This can be useful for migration, as PW's installer takes care of the installation for you.

Link to comment
Share on other sites

PW does have a Profile Export module that lets you create a site profile that can be imported elsewhere. This can be useful for migration, as PW's installer takes care of the installation for you.

Ryan, does the profile exporter also export users and premissions?

Link to comment
Share on other sites

Thanks Ryan, exactly what I needed.

Thumbnails - this is the way I wanted it to work, but watching some video it seemed to me that it took thumbnail from the center. Great.

So migration is pretty easy - I like that. I have some experience with wordpress, and it is quite hard there when you change domain name.

Now I'm learnig php little bit encouraged by ProcessWire elegance and simplicity. Thanks for that framework.

When I will have more noob questions, I'll ask here :)

  • Like 1
Link to comment
Share on other sites

Ryan, does the profile exporter also export users and premissions?

Users, roles and permissions are not included in a site profile. The module specifically excludes them. Though if you wanted it to include them, it would just be a matter of removing a line from the module, so will probably make this a configuration option on the next update.

Link to comment
Share on other sites

Users, roles and permissions are not included in a site profile. The module specifically excludes them. Though if you wanted it to include them, it would just be a matter of removing a line from the module, so will probably make this a configuration option on the next update.

Hmm, so this wouldn't be a good idea to use it for transfering a site? I mean if the site has perimissions and roles, users setup (also on templates) this information wil get lost?

Link to comment
Share on other sites

Hmm, so this wouldn't be a good idea to use it for transfering a site? I mean if the site has perimissions and roles, users setup (also on templates) this information wil get lost?

The profile exporter is good for launching a new site, but not for migrating an existing one (for the reason you mentioned). For migrating an existing site, I think there's no better way than to copy the files from 1 server to the other (I use rsync) and then dump the database on old server, and import to the new. Then update /site/config.php to account for the new site's database host/login/password.

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...