joer80 Posted January 19, 2015 Share Posted January 19, 2015 I am wanting to make a Markup Generation module, but I am struggling with the best way to do it. What I am thinking so far, is have the template.php file hold the header, run my module function, and then the footer. All content rows would be handled by my module and it would spit out rows. You would pass the $page variable into my function, and it would loop through the $page->field items, and when it got to one, access the field like $page->field. So to create a row on a page, you would just add a field to your template with no need to ever edit the template file. When it gets to a field, it checks another function for what html to surround that data with, and echos both. ie. a PageTitleBackground field group may spit out a div that uses css to set a certain height and width with a background image, and this div may have an H1 inside it as well. The end result would be a row that has a background and an H1 page title. This is working great for rows that can be handled with one field, but I am at a loss with how to group a few fields into one row, but still allow the user to reorder the rows by changing the field order on the template. I can group fields with FieldsetOpen, but the user has to move 3 fields just to reorder a row. (Start, field, close.) I can group them with a repeater, but by nature, it doesn't really repeat and it looks like it might be unnecessary overhead to do it this way? I might could do it, but I would probably have to figure out how to turn off the ability to add another item. Is there another way to group fields? Any advice? Link to comment Share on other sites More sharing options...
kongondo Posted January 19, 2015 Share Posted January 19, 2015 I am struggling to understand why this should be a module? You can pretty much run this as a function included in your template file. I am also not getting the question, what do you mean by grouping fields? Maybe give an example? And what does a FieldSetOpen have to do with a Markup module? Link to comment Share on other sites More sharing options...
joer80 Posted January 19, 2015 Author Share Posted January 19, 2015 My end result would be a module that when installed, would automatically add html to every field on a page as well as inject a css file in your head section. It would also come with some extra fields, that held other fields that you can plop on your template, and move the group around all at once.. ie. You may setup your "Home" page with these fields and move them around to change their order: TitlewithBackground - Contains sub fields of H1 (text), Background (image) Body Row with picture - 2 columns that contains 1 text area and photo on right (image) Featured Content Row 4 Column Paralax - Contains 4 text areas, one ta for each column, and a paralax image background. etc. The idea is to allow someone to download a module, and use the fields it comes with to build a website using predefined row groups. Link to comment Share on other sites More sharing options...
kongondo Posted January 19, 2015 Share Posted January 19, 2015 OK, in essence, a website builder... Link to comment Share on other sites More sharing options...
joer80 Posted January 19, 2015 Author Share Posted January 19, 2015 Pretty much. I am thinking I may need to make each row I design a repeater field that does not allow new items? Link to comment Share on other sites More sharing options...
joer80 Posted January 20, 2015 Author Share Posted January 20, 2015 I worked on a new field that is like the repeater but does not repeat last night but did not finish. If you guys think of a better way, let me know! I will keep trying! Link to comment Share on other sites More sharing options...
Soma Posted January 20, 2015 Share Posted January 20, 2015 I think you're looking for repeater or pagetable field https://processwire.com/talk/topic/6417-processwire-profields-table/page-2#entry63119 And for PageTable there's a extended version. https://processwire.com/talk/topic/7459-module-pagetableextended/ 1 Link to comment Share on other sites More sharing options...
joer80 Posted January 20, 2015 Author Share Posted January 20, 2015 Repeater would be great if it was possible to give it a max number of entries and it would turn off the add button after say, 1 of group of items was added. Or how ever many your row is designed to hold.PageTableExtended may be perfect for what I am after. I will take a look tonight! Link to comment Share on other sites More sharing options...
joer80 Posted January 21, 2015 Author Share Posted January 21, 2015 I dont think PageTable or PageTableExtended is what I am after. You seem to be required to have a template file in your root for each one, with fields tied to each template. I don't want all of my row possibilities in my root, and I cant make a generic template file because all fields I would ever use would need to be tied to it, and I dont want every field in every row. I think repeater will work because I am not required to put the template in root. I can include that snippet from a more organized source located in my module directory. I just wish there was a way to remove the add new button on rows that do not support more than one. I may see if I can mess with it some more soon! Link to comment Share on other sites More sharing options...
joer80 Posted January 21, 2015 Author Share Posted January 21, 2015 The overview so far: Assuming a Basic-Page.php template, import the module at the top of the page, and call the buildRows function passing in your page var where you want them placed. (If you want it to inject css, you may need to call a buildCSS function in the head section also.) The module would look at the field names tied to the page in the correct order, and look up the correct include file, and return that row html with the data from the page placed in it. I could have a folder structure like this so you could switch which frontend framework you wanted to use: bootstrap/ foundation/ bootstrap/content/ bootstrap/content/50-50-Content-Image.php bootstrap/content/75-25-Content-Image.php bootstrap/content/100-H1-Body.php bootstrap/content/100-Buttons.php I could also add a background image field just in case you want to upload a background image for that group. Maybe could add a checkbox if you want it to be parallax or regular? Just my thoughts! Link to comment Share on other sites More sharing options...
LostKobrakai Posted January 21, 2015 Share Posted January 21, 2015 While I still can't image what exactly you're trying to archieve, I don't think repeaters are the thing you need. Repeaters do what the name suggests, they repeat a single kind of contentblock. Currently only pagetables are able to show/group different "subtemplates" into a page, which seems like what you want to do with your content blocks. As to your request of disabling the repeater button. You could write a module which extends the repeater and includes a simple javascript file to hide the button after a given number of items. Additionally you could then hook into the page saving and look for the number of repeaters and delete potential excess ones. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now