Closed regystro closed 2 years ago
You are not missing anything. The current way of handling fragments is due to the developmental nature of the plugins: at the moment, the fragments are used to build links, but they are not rendered to HTML. This is because I have yet to find a clean way to mesh the generation of these identifiers with the default wiki header identifiers.
What does work is the following:
===== item1 =====
<data myitem #item1>
SampleField: One
</data>
That way the rendered links will jump you to the header.
Does that help you out?
Yes it kind of does. And I've been able to avoid duplicated headers by using Wrap plugin and including a custom CSS class this way:
.wrap_header-hidden h2 {
visibility: hidden;
position: absolute;
}
Then my data entry looks like this:
<WRAP header-hidden>
===== item1 =====
</WRAP>
<data myitem #item1>
SampleField: One
</data>
So let's say this workaround works for me :+1:
Thank you!!
Good to hear!
I'll leave this issue open, since there should be a solid solution for this problem. (Workarounds are nice, but we really want this to work out-of-the-box.)
Hi.
I managed to write a little mod and got it working. Now there's no need to include the headers (===== item1 =====
) nor the CSS to hide them as stated in some posts above :)
Just wanted to share in case anyone is interested.
Strata Plugin version 2017-03-28
File: lib\plugins\strata\syntax\entry.php
Replace the original line #252
$R->doc .= '<div class="strata-entry" '.(isset($currentPosition)?'id="'.$currentPosition.'"':'').'>';
by all this code:
// ## internal link MOD ##
$divid = $data['entry'];
resolve_pageid(getNS($ID),$divid,$exists); // convert entry title to id using DokuWiki function
// translate id to match the link generated by Strata Plugin
$divid = preg_replace('/[\.:]/','',$divid); // remove unwanted characters
$divid = preg_replace('/#/','_',$divid); // replace particular characters
if (isset($previousPosition) or isset($nextPosition)) {
// has fragments
if (!isset($previousPosition)) $R->doc .= '<span id="'.$divid.'"><span>'; // added as bookmark to first fragment
$R->doc .= '<div class="strata-entry" '.(isset($currentPosition)?'id="'.$currentPosition.'"':'').'>'; // yep, that's the original line
} else {
// single entry
$R->doc .= '<div class="strata-entry" '.(isset($currentPosition)?'id="'.$divid.'"':'').'>'; // use our generated id instead
}
// ## END internal link MOD ##
You may use this code to test it:
~~NOCACHE~~
<data myitem #item1>
SampleField: One
</data>
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
<data myitem #item2>
SampleField: Two
</data>
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
<data myitem #item3>
SampleField: Three
</data>
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
<data myitem #item4>
SampleField: Four
</data>
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
<data myitem #item4>
SampleExtraField: Another fragment
</data>
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\
<table ?item>
?item is a: myitem
</table>
Now you can click on the links at the table and they take you to the related data entry.
Greetings :)
Hi.
Trying to figure out how to accomplish this, but having read all documentation, I can't get it to work.
I have a single page named
datapage
containing all data objects of class "item":and so on... What I want is a simple table showing direct links to each item, so I use:
And I end having a table which links to
datapage#item1
,datapage#item2
anddatapage#item3
But having a look at the HTML code I've found there are no HTML sections / anchors defined as #item1 .. #itemN, so no direct linking possible, and that's what I need. When I click on the links I'm always redirected to the top of the
datapage
. Is there any way to do this? Am I missing anything in the item / fragment approach?Thanks a lot in advance. Greetings.