PHPWord Prevent rows from the same table appearing on different pages - php

thanks for help with previous PHPWord issue. I have another.
I'm creating documents with tables where each table is basically used as a stylized container for a list of items. For example, in my case i have a collection of legal definitions. Each definition has a code, title, and textual description that appears in a table. So when there's multiple definitions, each definition has its own table, and appears like so:
and so on. Each table isnt really a table, its more i'm kind of hijacking tables to stylize my document. The problem is when I have a long list of items, invariably some of the tables will be split between pages where the top row of the table will be at the very bottom of the page and bottom row of the table will be at the very top of the next page, like so
This is very undesired. Is there any way to tell PHP word that "hey, if this table is going to be split between pages, just put the whole table on the next page" ??
I'm also using PDFmake for making pdf's and it has a pageBreakBefore function that can be used for exactly this purpose. I notice that paragraphs have a pageBreakBefore style which can force each pragraph to appear on a new page, but this isnt what i'm looking for. Is there some way i can maybe get into how PHPWord builds the document to put a conditional test in maybe?
Any input is greatly appreciated thanks.

I had the same problem .... and found the answer today in "normal" MsWord documentation. I found the equivalent in the phpWord doucmentation, tried it and it works:
In your paragraph formats, set 'keepNext' => true

Related

Yii Cgridview Dynamic Columns

I am looking at customising the yii cgridview. I want to be able to allow users to select which columns they wish to see. Currently I am selecting the exact columns which will be displayed.
I have had a look for information on this but do not seem to be getting very far, maybe I am not looking for the correct terms or their is a specific term for this. Ideally users can click a button and tick the boxes which will be seen. I have seen this implemented on x2crm
http://demo.x2engine.com/index.php/accounts/index
I also like the ability to move the columns around ie resort the order of the columns and the ability to resize the columns when more are added. I realise someone isn't going to come along and do this for me, but certainly if someone could provide me any information or similar requests, it would be greatly appreciated.
After a long gruelling search I have found something that may in fact be the solution to both of my requests. An extension for Yii exists that allow for you to chooser the columns you wish to display with a simple tick box selection, as well as allowing for reordering of columns.
http://ecolumns.demopage.ru/index.php
The link above takes you to the demo page for the extension and the link below is the link to the extension download page.
http://www.yiiframework.com/extension/ecolumns/
This is by far the easiest way to implement this functionality on your web app.
Start by reading the docs for CGridView,
The constructor for it takes in an array specifying which columns to display (and whether to allow sort on them, etc) so allowing users to select which columns they want to see is almost trivial:
Display a form with checkboxes, the values of which are the names of the columns. When the user submits the form, loop over the checkboxes and add each of the present fields to the array that is passed to CGridView.
It is a little more complicated if you want to have specific settings for the column (i.e. a specific column header, or formatting) however not too much - in that case you just define an array holding the settings for it, and add that array to the total array you submit to CGridView.
Allowing drag and drop of the columns is a far more challenging enterprise, and may not actually be possible without a custom implementation - this is because CGridView is inherently just a table i.e. you could drag and drop rows easily (as they are whole items), but dragging a dropping a row is in reality dragging and dropping a lot of separate cells. However, there are jQuery examples that could get you started - and it wouldnt be a huge issue to implement a CGridView that uses divs instead of a table, and uses cells inside columns, rather than cells inside rows.
I hope that helps a little.

I need to echo more columns from my Mysql

So far - and with great support from SO members, I am at the edge of finishing my Music Database program, along with all its complexities... As previously suggested, I am using Mysql, Php, JQuery and DataTable plugin, which gives great paginated results. All my Search results work as intended.
My database holds 15 columns of data. I have one table (OK for my current needs). I am able to currently POST and ECHO 12 columns of Search results within a 900px table.
To finalize my project, I also need to be able to show 3 more columns of - data which holds longer text (song description (150 Char), Producer Name(80 Char), and Publisher Name (80 Char), which obviously will not fit on this size table, even with wrapping - on the same row echo.
BUT how do I POST the last 3 columns in a SHOW/HIDE hidden div?, so users maybe click on a link and have these 3 pieces of information suddenly appear underneath any one row on the 900px table?
I have struggled for hundreds of hours just to get to this final stretch...So I need a final suggestion (or push off a cliff) as to where to look next for this answer...
Thank you in advance for any "easy" to understand suggestions you may have to offer me!!
Since you said that you are using datatable plugin, You can use following example to display lengthy details. Once you click on expand button, it will expand the particular row.
http://datatables.net/release-datatables/examples/api/row_details.html
Users don't need (and usually don't care) about all this information. Allow them to configure which columns they can see, and if they choose too many for the width then it's not your problem.
Create a link in your furthest right hand column (for example). Use an anchor link like this:
See More
In the next table row, put in a hidden <div id="extra-<?php echo $counter; ?>" class="hidden-more-data">..your data here..</div>
You can structure your data any way you like in those elements.
In CSS, you can hide .hidden-more-data with {display:none;}
Using jQuery, you can use $('.see-more').live('click',function(){}); in this kind of fashion:
$('.see-more').live('click',function(){
var href = this.href;
$(href).toggle();
return false;
});
And various similar possibilities.
use short headings and show full headings on mouse-over or title attribute.
Show limited char in table cells. And for detailed view show them in pop up div's or mouse-over events.

Programming a Tags Feature in PHP

How would I go about writing up a basic tags feature? (similar to the one on this site)
I'm struggling coming up with good logic with little redundancy and would like a more experienced programmer's take on this.
The site I have is fully developed as of right now and has a search feature (searches through titles) - I'm just looking to expand on this and allow the search to sift through tags as well.
Edit:
I was considering adding a row on to my main table called "tags". Then separating them by spaces.
But I have also thought about create a new table and using the same id's from my main table, creating tags in this manner.
I'd suggest 2 tables. One contains Tags - the name of the tag, a tag id, any anything else you want to keep track of on a tag. Also create a relationship table that connects your article/post id to the tag id. You won't repeat data in the database, you should be able to search the tags and join tables together to come up to return articles, and also query the tags if you want to display them along with posts.

Dynamically generate a table with specific rowspans in PHP?

I've been racking my brain about an easy way to generate an HTML table with rowspans with PHP that would look like this, numbers indicating each cell's rowspan:
I noticed that there is sort of a pattern in the rowspans if you go from left to right, top to bottom: 1,3,7,1,1,1,1,1,3,1,1. I'm not sure if that matters.
Also, I wonder if it's possible to use any method for the table above for a table like this:
maybe addressing your second example first is easier, but it might be adapted to the first example.
the structure of the tables in html is obtained using the rowspan an colspan properties.
try to picture the table as a closet, the rows as drawers and cells as boxes inside those drawers.
with these properties, u can "merge" the cells throughout rows and/or columns.
my approach would be to set a minimal block with the appearance and data that you need, ie your second example, and write it down in html.
the "php-cycle-the-thing-up" part would require you to use that html "template" in the loop dropping your recordset data in the td portions of the html.
in that way, i think you might get what your looking for.
on the other side, if you need the php to create the table dynamically, and merge the cells automatically in a set pattern, or even ignoring the pattern and simply adapt the structure as the data is coming, it would probably be better to look at the structure from the end.
because of the way that tables are built with html, nesting table-tr-td, building cycles with this look is tricky. have you considered simply nesting divs?
i'm new to stackoverflow, i wanted to comment but by the time i finished this, i couldn't remove the answer nor comment the question, sorry if this didnt quite help you... :S
write down, come up with the recursion formula for the table. you need to come up with the math with the least number ideally ZERO conditional statements.
it's not that hard. for a desktop, i use three columns if it detects a mobile devices, my php automatically switches to 1 or 2 columns depending upon screen size

Multiple column articles in Joomla

I've got a client that requires that an article be displayed in two, sometimes three, columns in Joomla. I am fairly sure they won't be happy with having to edit 3 articles for 3 columns so the splitting would have to be done automatically.
I've done something similar before where it'll split a chunk of HTML into n columns, but have no real idea how to accomplish this within Joomla itself.
Any ideas gratefully recieved!
An alternative approach:
Use Javascript to split up the Article in several column in the browser. Here I could imagine a full-automated approach could work.
Advantages (over the first approach):
As Javascript can know, which height the paragraphs actually have in the browser (unlinke PHP), you could find the optimum split more accurately.
This can be implemented in the template php-File: you tell the template to include the js-File. So it could be made context-dependent,E.g.: If the left column is collapsed (because there are no modules in it), tell the JavaScript-File to initialize to 3 columns, else 2 columns.
However, have in mind that it should rest usable for those who have Javascript disabled.
This doesn't seem to be easy.
At first thought this should be an CSS attribute, but if it exists, it is part of CSS 3.0 and as such only understood by modern browsers (if at all). But I didn't find any way to do this in CSS.
So you actually have to modify your HTML code. I would propose the following:
A Button (editor-xtd plugin) that splits the article into several parts, each one for one column, showing a dotted line in the editor box (similar to the "read-more"-Button).
E.g. it inserts in the article: (you will have to define hr.column in /templates/system/css/editor.css).
A (content) plugin that creates the multiple colum-style,
E.g. replacing the hr-Tag with table or floating divs.
This way, it is half-automized, without mangeling in the Joomla! files but only adding to extensions to it.
the CSS 3 rules for multi-columns are:
-column-width
-column-gap
-column-rule
-column-count
with the vendor label (-moz, -webkit) before.
More info at http://www.css3.info/preview/multi-column-layout/
I would use css and tell the people with Explorer to change browser! (i'm jocking of course)
Otherwise javascript is the way like said before. This script should do (not tested) http://13thparallel.com/archive/column-script/
This should be done through the template, some PHP coding is involved.
One of our clients asked us to do the exact same thing before, and we have done it through template. Note that for very small articles we increased the font in order to split the article into 3 columns.

Categories