On 2014-03-07, 1:13 AM, Alastair Sherringham wrote:
>> That's probably due to the absolute positioning that Vector's css uses.
>> You'll have to add some extra css of your own to tweak the top position
>> of stuff, or add a relative positioned wrapper around vector's normal
>> content to contain the absolute position within a box you can push down.
> Yes, I think I need to look at some CSS and re-position.
>
> A quick question - Bill's way of adding a header/banner is just to write
> some HTML directly after the very minimal PHP code as per your tutorial
> (i.e. after "class SkinZedDocs extends SkinVector {", terminated). This
> is a much smaller and simpler file obviously that copying all the
> template code from Vector.php. If one only wants to add a banner/header
> to the output, is there any reason to do it the "long" way over the
> short and sweet way?
Firstly, because I misread the question/technique I'm going to give an
answer to a different question, one you didn't ask ;).
"What's the advantage of making a subclass of VectorTemplate and just
copying all of the execute() method instead of simply copying all of the
VectorTemplate and renaming it?"
Strictly speaking, since the majority of Vector's html is in the
template class' execute method instead of broken up or given some form
of insertion points, tweaking that technique to include a template
subclass with only a copy of execute in it isn't all that much smaller.

The advantage would be that you're still not 100% copying code and if
one of the non-overridden methods is changed you don't have to re-copy
anything.
The disadvantage would be that those few non-overridden methods aren't
considered as "public" as the rest of the skin, so there is a slight
possibility that someone may make a modification simultaneously to
Vector's execute method in core and one of those non-overridden methods
that breaks in your clone of Vector because the non-overridden method
depends on the changes to execute() that are not in your skin.

As long as you're only duplicating the template portion and keeping the
rest like my tutorial either way you still have the advantage of not
duplicating Vector's pile of css.
Of course neither is really ideal since in both cases a the majority of
Vector's template is being duplicated.

Depending on what you want to add and where you want to add it there is
a better trick that can be used.
Look around the template for the skin you are extending at it's uses of
$this->data['somekey'], $this->html('somekey'), $this->text('somekey').
See if the spot you want to insert your html has one of those and it's
the right type (ie: You're not trying to insert raw html in a spot that
uses $this->text('somekey').

If you find one instead of copying all of execute you can use a hack
where you extend execute(), modify $this->data (which is used by ->html
and ->text), then just let the parent skin's normal execute() method run
with the modified ->data instead of duplicating it.

function execute() {
    // Modify $this->data['somekey']
    parent::execute();
}

Then you keep all the advantages.

~Daniel Friesen (Dantman, Nadir-Seen-Fire) [http://danielfriesen.name/]


_______________________________________________
MediaWiki-l mailing list
MediaWiki-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-l

Reply via email to