Page 1 of 1

WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 11:48 am
by user1234
Hi again,

I need input on the following problem:

I need a table added into a) static pages (very often) and b) entries (sometimes) at will by a total HTML noob.

A large part of that table can be formatted/pre-written right away, as it is always the same (a pedigree of 4 generations). The only things which change is the individual content of the table cells.

The idea is to have either sort of a button which at least calls the html into the entry or (much preferable) an additional entry field (like "entry body" and "extended body" a third field e.g. "pedigree"), which hold the pedigree content fields, which when filled in create the finished table in the entry and static page. The latter solution would be preferable, as it's easy for a noob to use.

Anyone of the plugin wizards here have an idea, how to do something like this? I can't write code, but from my simple mind I have the feeling that there are a few content delivering plugins which could be adjusted to do something like this. Additionally I have the suspicion that such a plugin might be interesting for loads of people using s9y for genealogy or animal blogs. I can provide the html markup of what it should look like in the end and can advise on a frill here and there which might make this one a good, solid plugin.

Are there any takers?

Cheers,

Dachs

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:23 pm
by onli
There already is a fitting plugin: The custum editor toolbar buttons (serendipity_event_typesetbuttons). Using that, you could insert the html.
sincerely

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:30 pm
by user1234
Hi,

I already installed and tried it, but apparently I have trouble with the syntax. The code I tried to use is:

Code: Select all

Pedigree@<table width="98%"  border="1" cellpadding="0" cellspacing="0" bordercolor="#000000">
  <tr>
    <td rowspan="8"><div align="center">F</div></td>
    <td rowspan="4"><div align="center">FF</div></td>
    <td rowspan="2"><div align="center">FFF</div></td>
    <td><div align="center">FFFF</div></td>
  </tr>
  <tr>
    <td><div align="center">FFFM</div></td>
  </tr>
  <tr>
    <td rowspan="2"><div align="center">FFM</div></td>
    <td><div align="center">FFMF</div></td>
  </tr>
  <tr>
    <td><div align="center">FFMM</div></td>
  </tr>
  <tr>
    <td rowspan="4"><div align="center">FM</div></td>
    <td rowspan="2"><div align="center">FMF</div></td>
    <td><div align="center">FMFF</div></td>
  </tr>
  <tr>
    <td><div align="center">FMFM</div></td>
  </tr>
  <tr>
    <td rowspan="2"><div align="center">FMM</div></td>
    <td><div align="center">FMMF</div></td>
  </tr>
  <tr>
    <td><div align="center">FMMM</div></td>
  </tr>
  <tr>
    <td rowspan="8"><div align="center">M</div></td>
    <td rowspan="4"><div align="center">MF</div></td>
    <td rowspan="2"><div align="center">MFF</div></td>
    <td><div align="center">MFFF</div></td>
  </tr>
  <tr>
    <td><div align="center">MFFM</div></td>
  </tr>
  <tr>
    <td rowspan="2"><div align="center">MFM</div></td>
    <td><div align="center">MFMF</div></td>
  </tr>
  <tr>
    <td><div align="center">MFMM</div></td>
  </tr>
  <tr>
    <td rowspan="4"><div align="center">MM</div></td>
    <td rowspan="2"><div align="center">MMF</div></td>
    <td><div align="center">MMFF</div></td>
  </tr>
  <tr>
    <td><div align="center">MMFM</div></td>
  </tr>
  <tr>
    <td rowspan="2"><div align="center">MMM</div></td>
    <td><div align="center">MMMF</div></td>
  </tr>
  <tr>
    <td><div align="center">MMMM</div></td>
  </tr>
</table>@
That obviously didn't work. Do I need to add more @?

Also, for the kind of noobs I plan to use this for it contains way too much HTML for comfort. That's why a plugin which is just an already preformatted form into which fields the user would have to just feed in names would be much preferable. We are talking people here who are real HTML noobs, already at great discomfort seeing simple tags, and bowled over by any stretch of markup.

Cheers,

Dachs

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:36 pm
by user1234
Hi,

and to explain that table a bit more, "FF" or "MMF" translate into "Father's Father" (paternal grandfather) and "Mother's Mother's Father" (maternal great-grandmother). The person using that table would have to replace those placeholders with the actual names, e.g. "George N. Tubbs" and "Olivia Jones". Seeing it like that, it's easy to realize just how difficult this will be to someone who isn't able to imagine how that markup will look on the finished page.

Cheers,

Dachs

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:43 pm
by garvinhicking
Hi!

The best way for this, IMHO, would be to utlize the "Extended options for properties" plugin. With that, you could add any amount of "custom data" input fields you need. Like you add "weight1,weight2,weight3" to the list of fields in the configuration of the plugin, and then when you write a blog entry, you can simply fill in those fields.

Then at the template level on the display inside entries.tpl, near {$entry.body} or so, you need to do some coding, along the lines of:

Code: Select all

{if $entry.properties.ep_weight1 != ''}
<table>
<tr>
<td>weight</td>
<td>{$entry.properties.ep_weight1}</td>
</tr>
<tr>
<td>height</td>
<td>{$entry.properties.ep_weight2}</td>
</tr>
...
</table>
{/if}
The upside is total customization to the table layout to your references, the downside is that it's basically fixed on template level and that it can only be used in blog entries.

For staticpages there is a similar concept, but for that you'd have to do coding through the serendipity_event_Staticpage/backend_templates/default_staticpage_backend.tpl file, add your custom fields there, and then read them out inside the plugin_staticpage.tpl frontend plugin, according to the entries.tpl file.

So, for the amount of customization you need, there'd definitely be coding involved. I don't really know of a parametrized plugin that would suit your needs. If it were just simple variable replacement, the typesetbuttons plugin would be good, but for flexible table data insertion, you always need some kind of parseable syntax.

Maybe the way of creating tables through the "Textile" markup plugin is easier? It works like this:

Code: Select all

|   |_. Header A |_. Header B |
|_. Row 1 | A1 | B1 |
|_. Row 2 | A2 | B2 |
Textile is a Markup syntax that is available in many CMSes and Blogs, including Serendipity.

Garvin.

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:47 pm
by onli
Hi
For the records: The button-plugin didn't work for that because newlines in the html-code aren't allowed.

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 12:50 pm
by garvinhicking
Hi!

Another idea: You could enable the WYSIWYG editor, which has a powerful HTML Table editor, and let those people create a table through that. Once they've created it, they could even Copy+Paste it everytime they publish a similar blog entry.

Garvin.

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 1:00 pm
by user1234
Hi Garvin,

I believe I can do the first solution (for entries) myself, but I have trouble wrapping my brains around the second one for static pages. I really am no PHP/Smarty/JS coder :lol: as already was amply evident.
the downside is that it's basically fixed on template level
What do you mean by that?
Another idea: You could enable the WYSIWYG editor, which has a powerful HTML Table editor, and let those people create a table through that. Once they've created it, they could even Copy+Paste it everytime they publish a similar blog entry.
:lol: :lol: :lol:

Been there, done that, doesn't work! The people I talk about are really, REALLY noobs and they aren't going to develop a better understanding given time. My experience was that due to the fickleness of WYSIWYG editors (take just about any you want) already the copying often resulted in html totally askew and when it reaches the stage of writing/pasting content in the table cells, the end result usually is a table looking so godawful that none would be better. Frustration then is the immediate result and it ends up with me doing the stuff (which I do NOT want to keep doing). Anything above simple text-only stuff is really beyond most of these people.

That's the reason why I actually want to avoid any serious WYSIWYG stuff. It's enough if they can bold something, add images and adjust orientations of things.

Cheers,

Dachs

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 2:19 pm
by garvinhicking
Hi!

Okay, I do understand your WYSIWYG worries. In fact, you are right, when doing stuff like table layouting, the HTML is pretty much absurdly hard to grasp for a beginner, but also for a parser, due to the nesting levels of it.

So about the staticpage thing, I'll try to give you a quick run down. If you feel you could do on the blog-entry level, raising that to staticpages shouldn't be too hard, it's basically similar.

First thing to do is to implement the "custom properties" that you have in blog entries inside the backend of creating a staticpage.

That is done by editing the serendipity_event_staticpage/backend_templates/default_staticpage_backend.tpl template file. Note you can add any custom template file here, like backend_templates/genealogy.tpl for your purposes. You'll see a dropdown when creating/editing a staticpage on the top right corner, that you can use to switch the "views" you have.

Now, for starters I suggest to copy default_staticpage_backend.tpl to "genealogy.tpl" (you can even copy it inside your custom template directory, or the bulletproof directory, only take care it goes into a "backend_templates" subdirectory.

Now you take that file and we'll add a simply "weight1" and "weight2" field. We'll add that just before the "Submit" button; you can place it anywhere you like, but for now it's easier to describe when we simply but it before "{staticpage_input_finish}" like this:

Code: Select all

Enter weight1: <input type="text" name="serendipity[plugin][custom][weight1]" value="{$form_values.custom.weight1|@default:'None'}" />
<br />

Enter height: <input type="text" name="serendipity[plugin][custom][weight2]" value="{$form_values.custom.weight2|@default:'None'}" />
<br />
(Note to replace the 'weight1' and 'weight2' parts within the <input> twice: Once to show the value later on, and once for the fieldname. Anything apart from that inside the "name" attribute should not be edited, or your values will not be saved!

That was it already for the backend, you should now have your two input fields (remember: Only when you change the dropdown on the top right to "genealogy" - else you will be presented with the default template that does not contain your changes!).

Now we need to have it in the frontend as well, of course.

For that, you'll need to edit the template that you assigned to your default staticpages. By default, this is the plugin_staticpage.tpl template file. Note the staticpage plugin offers you to create any kind of "Static Page Type" where you can assign custom templates, so you could now go ahead to create a static page page type called 'Genealogy' with a custom file called plugin_staticpage_genealogy.tpl for example!

We'll go ahead with plugin_staticpage.tpl and edit that file. Now on to any place inside the HTML you'd like your Table output. I'd say directly below

Code: Select all

<div class="staticpage_content">{$staticpage_content}</div>
would be appropriate. Fill in:

Code: Select all

{if $staticpage_custom.weight1 != ''}
<table>
<tr>
<td>weight</td>
<td>{$staticpage_custom.weight1}</td>
</tr>
<tr>
<td>height</td>
<td>{$staticpage_custom.weight2}</td>
</tr>
...
</table>
{/if}
Remember that code? It's just $entry.properties.ep_ replaced with $staticpage_custom!

Have a try; I haven't had the time to actually perform my changes, but they should work fine. You might want to read the "ChangeLog" file of the staticpage plugin and search for version 3.70, where this method is explained a bit more.

HTH,
Garvin

Re: WANTED: Pedigree Display Plugin

Posted: Fri Sep 25, 2009 3:58 pm
by user1234
Hi Garvin,

thanks!

I'll try writing this tonight and will see how far I get with it. Will post back once I know more.

Cheers,

Dachs