Topic: @INHERIT wont work using TV in WayFinder  (Read 4722 times)

Pages: [1]   Go Down

#1: 6-Aug-2008, 10:20 AM

VanMeter
Posts: 37

I am calling a Template Variable in my WayFinder row template. But when I use @INHERIT as the default value for the TV it isn't pulling the value from the parent, it is just loading it empty.

Here is my Row Template:
Code:
<li[+wf.id+][+wf.classes+]><a href="[+wf.link+]" onMouseover="showtext('[+HeaderImage+]','[+HeaderText+]')" onMouseout="hidetext()">[+wf.linktext+]</a>
[+wf.wrapper+]
</li>

You'll notice I am calling the HeaderImage and HeaderText Template Variables. Which works perfectly fine if they are assigned a value. But if they are using the default value of @INHERIT, they are loading empty!

Does anyone know if this is a bug with WayFinder or am I missing something silly here...?

#2: 18-Aug-2008, 11:15 AM

VanMeter
Posts: 37

Any Ideas?

#3: 18-Aug-2008, 11:22 AM

Foundation

OpenGeek
MODx Co-Founder
Posts: 6,934

damn accurate caricatures...

WWW
Sounds like a bug; like it may not be processing the TV values properly.
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa

#4: 18-Aug-2008, 11:46 AM

Testers

dev_cw
Posts: 4,179

WWW
Is the parent published? I had a similar issue and it turned out that it was not inheriting the data since the document was not published.
Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]

#5: 29-Aug-2008, 10:00 AM

VanMeter
Posts: 37

INHERIT seems to work in the menu template, but only if you are on a page under the parent that it is inheriting from.

In other words, I think it is trying to INHERIT from the parent of the page you are viewing instead of its actual parent in the hierarchy.

Is this a bug that would be easily fixed?

#6: 29-Aug-2008, 10:33 AM

Testers

dev_cw
Posts: 4,179

WWW
I think that this is the way it is supposed to work.

If I have the following structure:

Quote
home
about
--sub 1
----subsub1
--sub 2
services
--sub 3
--sub 4
contact

And they are all using the same template variable that has @INHERIT set as the default value. Sub 1 will inherit it from 'about', sub 3 will get the value from 'services'. But subsub 1 will look to sub 1 for a value, if not found then it will go to 'about'.

However, if you have a value in sub 1, subsub 1 will get the value from sub 1 rather than from about.
Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]

#7: 29-Aug-2008, 11:05 AM

Coding Team

sottwell
Posts: 10,503

WWW
You are correct. @INHERIT will go up the tree and use the first value it finds.
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#8: 29-Aug-2008, 12:04 PM

Foundation

OpenGeek
MODx Co-Founder
Posts: 6,934

damn accurate caricatures...

WWW
This is a fundamental problem with the current architecture.  @INHERIT uses the $modx->documentIdentifier to start looking for parent values for the TV.  But in the case of getting these values on pages other than the actual page itself (i.e. via Wayfinder or Ditto), the @INHERIT will be using the wrong document id to start the search.  This architectural issue is another of the reasons I endeavored to build  Revolution, so each document could be treated as an object and be responsible for parsing it's own content, even when accessed from snippets on other pages.
Jason Coward
MODx Co-Founder
xPDO Founder
CTO @ Collabpad
work productively.
work intelligently.
work together.
Light is just a vibration of a note too. Everything is. You've got to keep that in mind.
  Frank Zappa

#9: 29-Aug-2008, 12:58 PM

Testers

dev_cw
Posts: 4,179

WWW
Quote
so each document could be treated as an object and be responsible for parsing it's own content, even when accessed from snippets on other pages.
Very cool.  Grin
Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]

#10: 29-Aug-2008, 01:05 PM

Coding Team
netProphET
Posts: 476

Time is Art

WWW
I submitted a change to fix this problem in Ditto a couple of months ago.
http://mirror3.cvsdude.com/trac/ditto/codebase/ticket/84
It's only a partial fix, but solves a certain class of problems for me. And sorry it's not a Wayfinder fix. I wonder if something similar could be done for WF?
« Last Edit: 29-Aug-2008, 01:23 PM by netProphET »

#11: 29-Aug-2008, 01:44 PM

Coding Team
netProphET
Posts: 476

Time is Art

WWW
In case anyone has time to attempt a fix/workaround for WayFinder, it looks to me like line 416 of wayfinder.inc.php is where the document's TV values are gathered. To get @INHERIT to work in these cases, I think you would have to check to see if the TV's value is @INHERIT, and if so, do the actual (intended) inheriting right there.

#12: 4-Sep-2008, 04:07 PM

VanMeter
Posts: 37

Seems like we are on the right track here. OpenGeek's description of the problem is exactly what I am experiencing.

PS: I am very excited for Revolution!

#13: 25-Jan-2009, 08:15 AM

bungo
Posts: 4

currently working on a peer2php application

WWW
I have a fix for this   Grin
The row parser works fine with tv's, it is just the outer and inner wrapper parser that isn't replacing them.
Apply netProphET's Ditto fix.  The code for this function is exactly the same as wayfinder.
I submitted a change to fix this problem in Ditto a couple of months ago.
http://mirror3.cvsdude.com/trac/ditto/codebase/ticket/84
It's only a partial fix, but solves a certain class of problems for me. And sorry it's not a Wayfinder fix. I wonder if something similar could be done for WF?

Then,  change the following lines to correct the wrapper parser.
Around Line 126
Code:
//Process the wrapper
if (!empty($this->tvList)) {
$usePlaceholders = array_merge($this->placeHolders['wrapperLevel'],$this->placeHolders['tvs']);
foreach ($this->tvList as $tvName) {
$phArray[] = $docInfo[$tvName];
}
}
else {
$usePlaceholders = $this->placeHolders['wrapperLevel'];
}


$subMenuOutput = str_replace($usePlaceholders,$phArray,$useChunk);
currently working on a peer2php application

#14: 16-Mar-2009, 12:14 PM

Moderator

kylej
Posts: 765

WWW
bungo,  do you have the code for this.  I would like to get the fix put into the next version of wayfinder, but the trac link no longer works.

Thanks in advance.

Kyle

#15: 17-Mar-2009, 02:50 PM

bungo
Posts: 4

currently working on a peer2php application

WWW
Yes, I use SVN.  I will attach? a patch.
currently working on a peer2php application

#16: 18-Mar-2009, 08:26 AM

Moderator

kylej
Posts: 765

WWW
That would be great.

#17: 18-Mar-2009, 08:53 AM

bungo
Posts: 4

currently working on a peer2php application

WWW
Just had to get into work.
I have attached a diff of the Wayfinder from 9.6.3, with my changes, and also posted them below.

Here is the modified function with the change from Ditto.  My changes in the previous post allow TV replacement in the wrapper as well.

Code:
function appendTV($tvname,$docIDs){
global $modx;

$baspath= $modx->config["base_path"] . "manager/includes";
    include_once $baspath . "/tmplvars.format.inc.php";
    include_once $baspath . "/tmplvars.commands.inc.php";

$tb1 = $modx->getFullTableName("site_tmplvar_contentvalues");
$tb2 = $modx->getFullTableName("site_tmplvars");

$query = "SELECT stv.name,stc.tmplvarid,stc.contentid,stv.type,stv.display,stv.display_params,stc.value";
$query .= " FROM ".$tb1." stc LEFT JOIN ".$tb2." stv ON stv.id=stc.tmplvarid ";
$query .= " WHERE stv.name='".$tvname."' AND stc.contentid IN (".implode($docIDs,",").") ORDER BY stc.contentid ASC;";
$rs = $modx->db->query($query);
$tot = $modx->db->getRecordCount($rs);
$resourceArray = array();
for($i=0;$i<$tot;$i++)  {
$row = @$modx->fetchRow($rs);
$resourceArray["#{$row['contentid']}"][$row['name']] = getTVDisplayFormat($row['name'], $row['value'], $row['display'], $row['display_params'], $row['type'],$row['contentid']);   
}

//new code direct from ditto
if ($tot != count($docIDs)) {
$query = "SELECT name,type,display,display_params,default_text";
$query .= " FROM $tb2";
$query .= " WHERE name='".$tvname."' LIMIT 1";
$rs = $modx->db->query($query);
$row = @$modx->fetchRow($rs);
foreach ($docIDs as $id) {
$defaultOutput = getTVDisplayFormat($row['name'], $row['default_text'], $row['display'], $row['display_params'], $row['type'],$id);
if (!isset($resourceArray["#".$id])) {
$resourceArray["#{$id}"][$tvname] = $defaultOutput;
//$resourceArray["#$id"]["tv".$tvname] = $resourceArray["#$id"][$tvname];
}
}
}
return $resourceArray;
}

* assets_snippets_wayfinder-from-r10-to-r39.diff.txt (1.73 KB - downloaded 72 times.)
currently working on a peer2php application

#18: 18-Jun-2009, 05:08 AM

DaveChild
Posts: 17

After speaking to netProphET and hacking around with the code, I've made similar changes to Ditto and Wayfinder and got @INHERIT working for both. Code is here.
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.