我是TYPO3的新手,我正在检查错误的代码,我看到一个不工作的href。 浏览器中的检查显示空href:
<a class="download" target="_blank" title="Initiates file download" href=""> here..</a>
代码是:
<a class="download" target="_blank" title="Initiates file download" href="{location.pdf.originalResource.publicUrl}"><f:translate key="tx_locations_domain_model_location.here" />..</a>
我不明白这个location.pdf.originalResource.publicUrl
!!
当我显示{location}时,我得到:Locations\Locations\Domain\Model\Location:102
我在文件夹中找不到这样的路径!!
我错过了什么!!
当我做
<f:debug>{location}</f:debug>
我明白了:pdf =&gt; NULL,我该如何修复它,在我的后端我选择一个PDF并保存。没有错误消息
更新:
我的Pdf字段为int(11) unsigned
,
这是我的TCA(typo3conf / ext / locations / Configuration / TCA / Location.php)
$GLOBALS['TCA']['tx_locations_domain_model_location'] = array(
....
'columns' => array(
....
'pdf' => array(
'exclude' => 1,
'label' => 'LLL:EXT:locations/Resources/Private/Language/locallang_db.xlf:tx_locations_domain_model_location.pdf',
'config' => array (
'type' => 'group',
'internal_type' => 'file',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
'uploadfolder' => 'uploads/pics',
'show_thumbs' => 1,
'size' => 1,
'minitems' => 0,
'maxitems' => 1
)
),
这是我的位置类:
<?php
namespace Locations\Locations\Domain\Model;
/**
* Location
*/
class Location extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
/**
* title
*
* @var string
*/
protected $title = '';
/**
* fullTitle
*
* @var string
*/
protected $fullTitle = '';
/**
* description
*
* @var string
*/
protected $description = '';
/**
* image
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $image = NULL;
/**
* secondTitle
*
* @var string
*/
protected $secondTitle = '';
/**
* secondDescription
*
* @var string
*/
protected $secondDescription = '';
/**
* address
*
* @var string
*/
protected $address = '';
/**
* howToGetIt
*
* @var string
*/
protected $howToGetIt = '';
/**
* thirdTitle
*
* @var string
*/
protected $thirdTitle = '';
/**
* thirdDescription
*
* @var string
*/
protected $thirdDescription = '';
/**
* googleMap
*
* @var string
*/
protected $googleMap = '';
/**
* pdf
*
* @var \TYPO3\CMS\Extbase\Domain\Model\FileReference
*/
protected $pdf = NULL;
/**
* pricingtpl
*
* @var int
*/
protected $pricingtpl;
/**
* category
*
* @var \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Locations\Locations\Domain\Model\Category>
*/
protected $category = NULL;
/**
* __construct
*/
public function __construct() {
//Do not remove the next line: It would break the functionality
$this->initStorageObjects();
}
/**
* Initializes all ObjectStorage properties
* Do not modify this method!
* It will be rewritten on each save in the extension builder
* You may modify the constructor of this class instead
*
* @return void
*/
protected function initStorageObjects() {
$this->category = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
}
/**
* Returns the title
*
* @return string $title
*/
public function getTitle() {
return $this->title;
}
/**
* Sets the image
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $image
* @return void
*/
public function setImage(\TYPO3\CMS\Extbase\Domain\Model\FileReference $image) {
$this->image = $image;
}
/**
* Sets the pdf
*
* @param \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
* @return void
*/
public function setPdf(\TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf) {
$this->pdf = $pdf;
}
/**
* Removes a Category
*
* @param \Locations\Locations\Domain\Model\Category $categoryToRemove The Category to be removed
* @return void
*/
public function removeCategory(\Locations\Locations\Domain\Model\Category $categoryToRemove) {
$this->category->detach($categoryToRemove);
}
/**
* Returns the category
*
* @return \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Locations\Locations\Domain\Model\Category> $category
*/
public function getCategory() {
return $this->category;
}
/**
* Sets the category
*
* @param \TYPO3\CMS\Extbase\Persistence\ObjectStorage<\Locations\Locations\Domain\Model\Category> $category
* @return void
*/
public function setCategory(\TYPO3\CMS\Extbase\Persistence\ObjectStorage $category) {
$this->category = $category;
}
}
答案 0 :(得分:0)
您的模型Location.php
文件。您不能仅使用set方法定义getPdf()
方法。请在getPdf()
文件中定义第一个Location.php
方法。
喜欢这个。
/**
* Returns the pdf
*
* @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
*/
public function getPdf() {
return $this->Pdf;
}
您可以像.html
一样调试<f:debug>{_all}</f:debug>
文件并查看调试输出。
答案 1 :(得分:0)
您不必使用像<a href=""/>
这样的畅销内容,您可以在流畅的文档中找到<f:link..>
,<f:uri..>
等,以生成链接。
但是对于文件下载,你必须使用这个viewhelper。您只需要知道文件的uid。在您的情况下{location.pdf.uid}
确保在使用之前已编制索引文件。
<v:resource.file additionalAttributes="{foo: 'bar'}" data="{foo: 'bar'}" identifier="[mixed]" categories="[mixed]" treatIdAsUid="1" treatIdAsReference="1" as="NULL">
<!-- tag content - may be ignored! -->
</v:resource.file>