Switch postition of attachments in an article

In this board you can talk about general questions about phpMyFAQ

Moderator: Thorsten

Post Reply
pit
Posts: 8
Joined: Fri Jul 29, 2016 9:44 am

Switch postition of attachments in an article

Post by pit »

Hello,

is it possible to switch the position of the attachments from the button to the top in an article?
So it would be easier to download attachment in long faqs.
I looked for it in the artikel.tpl, but couldn't find it.

Second question:
How can I set the user permissions of any new faq by default to access for all users?


Thanks in advance!
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Switch postition of attachments in an article

Post by Thorsten »

Hi,

you can move the position of the attachments in the template file artikel.tpl. The permissions should be access for all by default.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
pit
Posts: 8
Joined: Fri Jul 29, 2016 9:44 am

Re: Switch postition of attachments in an article

Post by pit »

Neither it effects anything to change the position nor to delete these lines in /faq/assets/template/default/artikel.tpl:

Code: Select all

                    [privateNotes]
                    <div class="pmf-private-notes">
                        <h4>
                            {notesHeader}
                        </h4>
                        <p>
                            {notes}
                        </p>
                    </div>
                    [/privateNotes]
The FAQs are still the same. Everytime with the attachment at the buttom.
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Switch postition of attachments in an article

Post by Thorsten »

Hi,

the posted code is for private notes, not attachments.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
pit
Posts: 8
Joined: Fri Jul 29, 2016 9:44 am

Re: Switch postition of attachments in an article

Post by pit »

I can't find anything with attachment in /faq/assets/template/default/artikel.tpl. The attachment is defined in {writeContent}, but I don't know were to edit the content of {writeContent}.
There is a section in Artikel.php, where "writeContent" is defined:

Code: Select all

$tpl->parse(
    'writeContent',
    array(
        'baseHref' => $faqSystem->getSystemUri($faqConfig),
        'writeRubrik' => $categoryName,
        'solution_id' => $faq->faqRecord['solution_id'],
        'solution_id_link' => PMF_Link::getSystemRelativeUri().'?solution_id='.$faq->faqRecord['solution_id'],
        'writeThema' => $question,
        'writeContent' => $answer,
        'writeDateMsg' => $date->format($faq->faqRecord['date']),
        'writeAuthor' => $faq->faqRecord['author'],
        'numberOfComments' => sprintf(
            '%d %s',
            isset($numComments[$recordId]) ? $numComments[$recordId] : 0,
            $PMF_LANG['ad_start_comments']
        ),
        'editThisEntry' => $editThisEntry,
        'translationUrl' => $translationUrl,
        'languageSelection' => PMF_Language::selectLanguages($LANGCODE, false, $availableLanguages, 'translation'),
        'msgTranslateSubmit' => $PMF_LANG['msgTranslateSubmit'],
        'saveVotingPATH' => sprintf(
            str_replace(
                '%',
                '%%',
                PMF_Link::getSystemRelativeUri('index.php')
            ).'index.php?%saction=savevoting',
            $sids
        ),
        'saveVotingID' => $recordId,
        'saveVotingIP' => $_SERVER['REMOTE_ADDR'],
        'msgAverageVote' => $PMF_LANG['msgAverageVote'],
        'renderVotingStars' => '',
        'printVotings' => $faqRating->getVotingResult($recordId),
        'switchLanguage' => $faqHelper->renderChangeLanguageSelector($faq, $currentCategory),
        'msgVoteUseability' => $PMF_LANG['msgVoteUseability'],
        'msgVoteBad' => $PMF_LANG['msgVoteBad'],
        'msgVoteGood' => $PMF_LANG['msgVoteGood'],
        'msgVoteSubmit' => $PMF_LANG['msgVoteSubmit'],
        'writeCommentMsg' => $commentMessage,
        'msgWriteComment' => $PMF_LANG['msgWriteComment'],
        'id' => $recordId,
        'lang' => $lang,
        'msgCommentHeader' => $PMF_LANG['msgCommentHeader'],
        'msgNewContentName' => $PMF_LANG['msgNewContentName'],
        'msgNewContentMail' => $PMF_LANG['msgNewContentMail'],
        'defaultContentMail' => ($user instanceof PMF_User_CurrentUser) ? $user->getUserData('email') : '',
        'defaultContentName' => ($user instanceof PMF_User_CurrentUser) ? $user->getUserData('display_name') : '',
        'msgYourComment' => $PMF_LANG['msgYourComment'],
        'msgNewContentSubmit' => $PMF_LANG['msgNewContentSubmit'],
        'captchaFieldset' => $captchaHelper->renderCaptcha($captcha, 'writecomment', $PMF_LANG['msgCaptcha'], $auth),
        'writeComments' => $faqComment->getComments($recordId, PMF_Comment::COMMENT_TYPE_FAQ),
        'msg_about_faq' => $PMF_LANG['msg_about_faq'],
    )
);
But there is also no string or something like this for attachment.
All in all I can't find out, where I can change the position of attachment in an article.
Thorsten
Posts: 15560
Joined: Tue Sep 25, 2001 11:14 am
Location: #phpmyfaq
Contact:

Re: Switch postition of attachments in an article

Post by Thorsten »

Hi,

you are right. I'm sorry. Here's the code for adding the attachments under the FAQ: https://github.com/thorsten/phpMyFAQ/bl ... #L124-L137

Please change the code to the following in artikel.php:

Code: Select all

// List all faq attachments
$attachments = '';
if ($faqConfig->get('records.disableAttachments') && 'yes' == $faq->faqRecord['active']) {
    $attList = PMF_Attachment_Factory::fetchByRecordId($faqConfig, $recordId);
    $outstr = '';
    while (list(, $att) = each($attList)) {
        $outstr .= sprintf('<a href="%s">%s</a>, ',
            $att->buildUrl(),
            $att->getFilename());
    }
    if (count($attList) > 0) {
        $attachments = '<p>'.$PMF_LANG['msgAttachedFiles'].' '.PMF_String::substr($outstr, 0, -2).'</p>';
    }
}
Add one entry in the artikel.php, e.g.

Code: Select all

        'writeThema' => $question,
        'writeContent' => $answer,
        'attachments' => $attachments,
        'writeDateMsg' => $date->format($faq->faqRecord['date']),
Then add the {attachments} template variable wherever you want in artikel.tpl.

bye
Thorsten
phpMyFAQ Maintainer and Lead Developer
amazon.de Wishlist
pit
Posts: 8
Joined: Fri Jul 29, 2016 9:44 am

Re: Switch postition of attachments in an article

Post by pit »

Thats awesome! Thank you very much, it works perfectly!
Post Reply