<![CDATA[ Placeholder as link doesn't work - My Forums]]> https://forums.modx.com/thread/?thread=103228 <![CDATA[Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555475
i cant set my placeholder as link in chunk:

Snippet:

$newsite = "24";
$modx->setPlaceholder('mysite', $newsite);

$mychunk = $modx->getChunk('site-tpl');
 
$res = $modx->getObject('modResource',$id);
$res->set('content',$mychunk);
$res->save();



Chunk site-tpl:
Here is my new site: <a href="[[~[[+mysite]]]]">My new Site</a><br>
TestID: [[+mysite]]


HTML:
Here is my new site: <a href="">My new Site</a><br>
TestID: 24



what is wrong here?]]>
joe-petts Nov 27, 2017, 03:15 PM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555475
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555609 joe-petts Dec 01, 2017, 11:33 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555609 <![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555603 Bruno17 Dec 01, 2017, 09:27 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555603 <![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555602
Quote from: BobRay at Nov 30, 2017, 11:03 PM
(the number in parentheses next to the TV's name in the Elements tree)

In the Elements tree i see only my tvs but not the regular tvs like uri, pagetitle, longtitle... Where i can see the tv for example "pagetitle"?


If i set my tv (2) für tvId, then i get the same result.

But i change the snippet and it works now:

$tv = "uri";
$id = "713";
$parent = $modx->getObject('modResource', $id);
return $modx->getOption('site_url'). $parent->get($tv);
]]>
joe-petts Dec 01, 2017, 09:01 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555602
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555584
The $resourceId, may also be wrong (try it with the correct TV ID first), but fixing it depends on where and how the snippet is called. Since I think it's in a Tpl chunk, this might work:


[[!snippetName? &docId=`[[+id]]` ]]


Then in the snippet:

$resourceId = $modx->getOption('docId', $scriptProperties);


]]>
BobRay Nov 30, 2017, 11:03 PM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work?page=2#dis-post-555584
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555545
i get only the option site_url and not the uri of the page. What i'm do wrong?

(its my tvId wrong? I dont know the id of uri..)

    $resourceId = $unterseiteid; //$modx->resource->get('id') ??
    $tvId = uri;
  
    $query = $modx->newQuery('modTemplateVarResource', array(
    'contentid' => $resourceId,
    'tmplvarid' => $tvId,
    ));
    $query->select('value');
    return $modx->getOption('site_url') . $modx->getValue($query->prepare());
]]>
joe-petts Nov 30, 2017, 10:51 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555545
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555525

$resourceId = 23; //$modx->resource->get('id') ??
$tvId = 12;
 
$query = $modx->newQuery('modTemplateVarResource', array(
    'contentid' => $resourceId,
    'tmplvarid' => $tvId,
));
$query->select('value');
$return $modx->getOption('site_url') . $modx->getValue($query->prepare());


Note that you would no longer need the site_url tag prefix.]]>
BobRay Nov 29, 2017, 06:10 PM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555525
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555502
It's possible to get the id's with my own snippet similare "FastField".

[[++site_url]][[!myFF? &tv=`uri` &id=`[[+unterseiteid]]`]]


But i hope find smarter way to solve that.]]>
joe-petts Nov 28, 2017, 12:18 PM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555502
<![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555501 ]]> Bruno17 Nov 28, 2017, 11:47 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555501 <![CDATA[Re: Placeholder as link doesn't work]]> https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555500
/*--------- Work vom Formular abrufen ---------*/
$work = $_POST["work"]; 

if (isset($work)) {

// Erstellt die Überseite
      
    $pagetitle = $work;
    $parent = "0";
    $alias = "my-". $work;
    $template = 3;
    $richtext = 0;
    $published = true;

$doc = $modx->newObject('modDocument');
    $doc->set('parent',$parent);
    $doc->set('pagetitle',$pagetitle);
    $doc->set('alias',$alias);
    $doc->set('template',$template);
    $doc->set('published',$published);
    $doc->set('richtext',$richtext);    
    $doc->save();
    $id = $doc->get('id');


// Erstellt die Unterseite

    $pagetitle3 = "Arbeit 1";
    $template3 = "3";
    $alias3 = "meine-arbeiten";
    $published3 = true;
    $hidemenu3 = true;

    $doc = $modx->newObject('modDocument');
    $doc->set('parent', $id);
    $doc->set('pagetitle',$pagetitle3);
    $doc->set('alias',$alias3);
    $doc->set('template',$template3);
    $doc->set('published',$published3);
    $doc->set('hidemenu',$hidemenu3);
    $doc->save(); 
    $unterseiteid = $doc->get('id');


//  Bearbeitet den Content der Startseite und fügt Verlinkungen zu den Unterseiten ein
 
    $properties = array();
    $properties['unterseiteid'] = $unterseiteid;
    
    $mychunk = $modx->getChunk('kat-templates',$properties);
    echo $mychunk;

    $res = $modx->getObject('modResource',$id);
    $res->set('content',$mychunk);
    $res->save();

}


My "kat-templates" Chunk:

<h1>Überseite von Work</h1>
<a href="[[~[[+unterseiteid]]]]">Hier geht es direkt zu den einzelnen Arbeitsbereichen</a>


Thats it.]]>
joe-petts Nov 28, 2017, 10:23 AM https://forums.modx.com/thread/103228/placeholder-as-link-doesn-t-work#dis-post-555500