ohthanks Posted December 12, 2012 Share Posted December 12, 2012 Hi everyone, Building out my second site on PR right now and ran into setup question I didn't know the best solution to, thought someone might have suggestions. The issue is with a services pricelist page that will have multiple tables of prices with table header and price/detail fields. Setting up a repeater field for each table with the associated itemlist fields (size, price, etc) is a fine solution, but I would ideally like to be able to create new pricelist tables within the page itself and the issue I have is that the tables have different numbers of columns and header titles. For example one pricelist would have say (Filesize, Price) and another has (Size, Print, Proof, Price.) It doesn't seem like there is any way to add/remove the fields associated with a page/repeater from the page editor itself, so what is my best option here for creating fields with variable columns? The only idea I have is to create a repeater with a preset number of content fields in each repeater row that and have the empty columns be left blank. Type Size Price null null type1 11x8.5 $10 null null and then test for value in the template and build the table columns based off that. That doesn't seem like the most elegant solution though, so any ideas would be appreciated. Thanks! Link to comment Share on other sites More sharing options...
Martijn Geerts Posted December 12, 2012 Share Posted December 12, 2012 Welcome to the forum ohthanks! I recommend using pages instead. Maybe something like this: product-page - table-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) - table-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) - table-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) - row-page (data-template) fields in the template: - data1 - data2 - data3 - data4 In the table-page (parent) it is used for the headers. The row-page (child) it is used for data. The template doesn't need a file, only used for storing data. Only populated fields in the table-page (parent), filled with header names are used for the table headers Now you know wich fields to use from the child pages. Each child page is a row in your html table. --- For large amount of data, you can use the import CSV to pages module. ---- I like to use the MarkupAdminDataTable. look in: /wire/modules/Markup/MarkupAdminDataTable/MarkupAdminDataTable.module it's straight forward & not that difficult to understand. here some sort of example: $table = $this->modules->get("MarkupAdminDataTable"); $table->setEncodeEntities(false); $table->setSortable(true); $table->headerRow(array('name', 'of', 'header', 'items')); foreach($table as $row) { $table->row(array($row->data1, $row->data2, $row->data3, $row->data4)); } echo $table->render(); 4 Link to comment Share on other sites More sharing options...
ohthanks Posted December 12, 2012 Author Share Posted December 12, 2012 Oh crazy, I will look into the admin data table more now. I would have never thought about doing it that way. I think after coming from EE matrix setups for so long I just try and use repeaters to solve everything. Thanks for the insight. You guys are great. 1 Link to comment Share on other sites More sharing options...
diogo Posted December 13, 2012 Share Posted December 13, 2012 I think after coming from EE matrix setups for so long I just try and use repeaters to solve everything. Not even one year ago there weren't any repeaters in PW. And still, we were all happy 2 Link to comment Share on other sites More sharing options...
masterofallarts Posted March 20, 2013 Share Posted March 20, 2013 Hi there, I'm now in something like the OP's situation and quite happy to find this thread. I have been trying to build something with repeaters in order to store table definitions for certain overview pages, and I think that storing the column metainformation as pages is a brilliant idea. Trying to get MarkupAdminDataTable going, I must be missing something basic and obvious. Martijn Geerts posted: foreach($table as $row) { $table->row(array($row->data1, $row->data2, $row->data3, $row->data4)); } but I don't see how $row->dataN can already be populated at this point. What am I supposed to be doing here? How do I refer to my existing subpages? It seems I'm not getting the logic of the module. I'm now able to use MarkupAdminDataTable, hooray! Nevertheless, I'm not sure what to do with the columns as related to pages. I have a page for listing computers, one for listing monitors and so on, for a variety of stuff. Each of these pages has children with a template 'monitors', 'computers', determining the fields of the children. Also, on each of the parent pages, I want to show a table with data of its children. I am looking for a way of storing the table structure (column header and respective field name of the children, where to get the data from) in the parent pages. I could put up an include for each parent page that just contains this information in an array, but this feels redundant. At the moment, I have a few half ideas, but it won't come together. Thanks! Link to comment Share on other sites More sharing options...
ryan Posted March 20, 2013 Share Posted March 20, 2013 Not sure I understand the question (if it's still a question?) but want to mention that MarkupAdminDataTable is just a markup generation helper, and you shouldn't feel confined to it. If you have some table generation needs that aren't being covered by it, there's no harm in generating your own table markup. Link to comment Share on other sites More sharing options...
masterofallarts Posted March 20, 2013 Share Posted March 20, 2013 Sorry for my garbled question. MarkupAdminDataTable is no longer problematic. It is rather the way that table-page and row-page (from Martijn Geerts' post) are related. Are the row-pages subpages, i.e. children of the table-pages? I can't seem to wrap my head around the following paragraph of Martijn's: Only populated fields in the table-page (parent), filled with header names are used for the table headers Now you know wich fields to use from the child pages. Especially the word 'now' puzzles me. The way I understand it involves separating the level of the product page (in my case, say, "Computers", which is supposed to show a table of all computers) and the level of the individual computers (which would have the template 'computer') with an additional level that will take a page for each table (which would have the template 'computer', too). Is that approximately right? I have thought that the table headers are to be stored in the product page directly. That would feel more natural to me, and the additional level looks a bit clunky. Thanks for babysitting me through this. Oh yeah, I forgot that I have multiple sorts of products that I'd like to display that way, only with varying table columns and numbers of columns, too. I'm just looking for a way to store that table info in the product page of sort. Link to comment Share on other sites More sharing options...
Martijn Geerts Posted March 20, 2013 Share Posted March 20, 2013 fields in the (folder) - data1 ( populateted with the header value "color" forexample )- data2 ( populateted with the header value "size" forexample ) - data3 ( populateted with the header value "amount" forexample )- data4 ( not set ) if you know, that data4 is false, then you don't have to get data4 field from it's children. ( This way, you're able to have a three column table ) 1 Link to comment Share on other sites More sharing options...
masterofallarts Posted March 21, 2013 Share Posted March 21, 2013 Martijn, thanks for elaborating! Finally it dawns upon me. I would not name the fields in the templates by the table headers, but simply dataN. I had always thought of things like array( 'color' => '$page->color', 'size' => '$page->size', 'amount' => '$page->amount . " pieces"' ); as the main source for table structure information, but I never could find where to put this array, if not in an include. I even tinkered with eval'ing the array values, because it would be nice to feed this array into a field on the product page, but I haven't been able to get anything of that to work. Anyone using arrays to define tables? 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