簡體   English   中英

TYPO3 href無法正常工作

[英]TYPO3 href not working

我是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 => 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;
    }



}

您的模型Location.php文件。 您不能僅使用set方法來定義getPdf()方法。 請在Location.php文件中定義第一個getPdf()方法。

像這樣。

 /**
 * Returns the pdf
 *
 * @return \TYPO3\CMS\Extbase\Domain\Model\FileReference $pdf
 */
public function getPdf() {
    return $this->Pdf;
}

之后,您可以像這樣<f:debug>{_all}</f:debug>調試.html文件,然后查看調試輸出。

您不必在Fluid中使用<a href=""/>類的東西,就可以在Fluid <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>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM