我正在使用Sitecore和Glassmapper,在我的模板中,我有一个drop link字段,我用它来链接到特定模板(X)的sitecore项目。在glass mapper生成的.cs中,此字段生成为Link字段,并且具有到模板X的sitecore项的targetID GUID。
我想知道,玻璃映射器是否有可能生成链接类型作为模板X.而不是每次都在itemid上运行get。
由于
答案 0 :(得分:0)
您可以选择解决方案资源管理器中列出的模板字段,然后将自定义数据设置为(不要忘记重新生成代码):
<?php
//Check Start
//echo "Program Starts";
// Include the library
include('/var/www/tools/dom/simple_html_dom.php');
$source = $url;
$content = array();
$header1 = array();
$header2 = array();
$i = 0; $y = 0;
// Retrieve the DOM from a given URL
$html = file_get_html($source);
//grab headers in case initial title is a header
foreach($html->find('h1') as $e){
$header1[$i] = $e->outertext;
//echo $e->outertext;
$i = $i + 1;
}
$i = 0;
foreach($html->find('h2') as $e){
$header2[$i] = $e->outertext;
//echo $e->outertext;
$i = $i + 1;
}
//reset counter
$i = 0;
// Find all paragraph tags and print their content into a text file
foreach($html->find('p') as $e){
$content[$i] = $e->outertext;
//echo $e->outertext;
$i = $i + 1;
}
//create the content storage file
$filename = "/var/www/html/nuzr/content/".$table.$titleid.".html";
echo "The filename is".$filename;
$file = fopen($filename,"a");
// write header and link to original article
$titleblurb = "<b>Original article courtesy of <a href='".$url."'>".$sourcename."</a></b>";
fwrite($file, $titleblurb);
// set site specific parameters based on header / footer size
if($sourcename == "The Globe and Mail"){
//Set indexing parameters
$z = $i - 13; $y = 2;
//Add Header content
$text = $header1[0];
fwrite($file, $text);
$text = $header2[1];
fwrite($file, $text);
}elseif($sourcename == "CNN Money"){
//Set indexing parameters
$z = $i - 3; $y = 1;
//Add header content
$text = $header1[0];
fwrite($file, $text);
$text = $header2[1];
fwrite($file, $text);
}elseif($sourcename == "CNN Markets"){
//Set indexing parameters
$z = $i - 3; $y = 1;
//Add header content
$text = $header1[0];
fwrite($file, $text);
//$text = $header2[1];
//fwrite($file, $text);
}elseif($sourcename == "BBC Business"){
//Set indexing parameters
$z = $i - 9; $y = 1;
//Add header content
$text = $header1[0];
fwrite($file, $text);
//$text = $header2[1];
//fwrite($file, $text);
}elseif($sourcename == "BBC Politics"){
//Set indexing parameters
$z = $i - 0; $y = 1;
//Add header content
$text = $header1[0];
fwrite($file, $text);
//$text = $header2[1];
//fwrite($file, $text);
}else{
echo $sourcename;
}
do{
$text = $content[$y];
fwrite($file, $text);
$y = $y +1;
}while($y<$z);
echo "Zeta is".$zeta;
$zeta = $zeta +1;
//close the content file
fclose($file);
//echo "File end.";
$html->clear();
unset($html);
?>