TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Recent posts

#1
Support / Re: Promote to Front Page
Last post by @rjen - Today at 05:04:34 PM
I do like the idea, althought there are some layout details I would change...
Although the 'Promote to Frontpage' was originally used for frontpage display, we could 'revamp' the function in a future release.

What would make it more universal:
- rename the 'Promote to Frontpage' to 'Make Promoted Topic'
- I can add an extra option in Article settings to allow switching the Promotion on and off (regardless of the Frontpage setting)
- I would add a standard block to Tinyportal to show Promoted topics

For the block I would like to use your input as the starting point. Would that be ok for you?
#2
Support / Re: Promote to Front Page
Last post by sgm09 - Today at 12:48:00 AM
Here's the code for the promoted topics block, as generated by chatgpt.
global $context, $smcFunc, $scripturl, $settings, $txt, $modSettings;

// Number of promoted topics to show
$promoted_limit = 15;

// Check if there are promoted topics
if (!empty($context['TPortal']['frontpage_topics']))
{
    $request = $smcFunc['db_query']('', '
        SELECT t.id_topic, t.id_first_msg, m.subject, m.id_member, m.poster_name, m.poster_time
        FROM {db_prefix}topics AS t
        INNER JOIN {db_prefix}messages AS m ON (m.id_msg = t.id_first_msg)
        WHERE t.id_topic IN ({array_int:topics})
        ORDER BY m.poster_time DESC
        LIMIT {int:limit}',
        array(
            'topics' => array_map('intval', explode(',', $context['TPortal']['frontpage_topics'])),
            'limit' => $promoted_limit,
        )
    );

    $topics = array();

    while ($row = $smcFunc['db_fetch_assoc']($request))
    {
        $topics[] = $row;
    }
    $smcFunc['db_free_result']($request);

    echo '
    <div style="display: flex; flex-wrap: wrap; gap: 1rem; width: 100%;">';

    foreach ($topics as $topic)
    {
        $member_id = (int) $topic['id_member'];
        $avatar_img = '';

        if (!empty($member_id)) {
            // Query avatar info directly
            $request2 = $smcFunc['db_query']('', '
                SELECT avatar, email_address
                FROM {db_prefix}members
                WHERE id_member = {int:id_member}
                LIMIT 1',
                array(
                    'id_member' => $member_id,
                )
            );

            if ($request2) {
                if ($row2 = $smcFunc['db_fetch_assoc']($request2)) {
                    $avatar_data = set_avatar_data(array(
                        'avatar' => $row2['avatar'],
                        'email' => $row2['email_address'],
                    ));

                    if (!empty($avatar_data['image'])) {
                        $avatar_img = $avatar_data['image'];
                    }
                }
                $smcFunc['db_free_result']($request2);
            }
        }

        // Fallback default avatar
        if (empty($avatar_img)) {
            $avatar_img = '<img src="' . $settings['images_url'] . '/default_avatar.png" alt="" style="width:50px;height:50px;border-radius:50%;">';
        }

        echo '
        <div style="display: flex; align-items: center; border: 1px solid #ccc; border-radius: 8px; padding: 10px; width: 300px; box-sizing: border-box;">
            <div style="flex-shrink: 0; margin-right: 10px;">
                <a href="', $scripturl, '?action=profile;u=', $member_id, '">', $avatar_img, '</a>
            </div>
            <div style="flex-grow: 1;">
                <div style="font-weight: bold; margin-bottom: 5px;">
                    <a href="', $scripturl, '?topic=', $topic['id_topic'], '.0">', $topic['subject'], '</a>
                </div>
                <div style="font-size: smaller; color: #666;">', $txt['by'], ' ', htmlspecialchars($topic['poster_name']), ' | ', timeformat($topic['poster_time']), '</div>
            </div>
        </div>';
    }

    echo '
    </div>';

}
else
{
    echo '<div class="smalltext">No promoted topics available.</div>';
}
#3
Support / Re: Promote to Front Page
Last post by @rjen - April 28, 2025, 10:05:08 PM
I do like the idea to create blocks with selected topics . Would you mind sharing the block code?

It may help formulating an alternative option...
#4
Support / Re: Promote to Front Page
Last post by sgm09 - April 28, 2025, 09:36:44 PM
Chatgpt is pretty clever indeed. So what do you suggest we use as an indicator then ?
I would disagree it's an edge case. Why should the idea of promoted topics be stuck to a particular display option, that is mandatory to be enabled for the promoted button to even appear ? This doesn't make much sense to me, in a project that allows extensive customization, custom php code blocks and so on.

Ok now I just found that there's sticky topics in smf, without mods. I willuse that :D
Still, the way this promoted posts is designed should be more flexible.
#5
Support / Re: Promote to Front Page
Last post by @rjen - April 28, 2025, 08:49:48 PM
I don't think so. Promote to front page is intended for exactly that.

If you wrote a custom block that uses that indicator than that's clever, but really an edge case. Not something we should adapt the core code to.

#6
Support / Re: Promote to Front Page
Last post by sgm09 - April 28, 2025, 08:32:01 PM
Quote from: @rjen on December 17, 2018, 03:24:11 PMI agree this is not very intuitive, especially since the 'Promote to frontpage' button is showing even when the chosen frontpage layout will not show the topics.

I think we should only show the button if the button can actually be used. I can fix this in the next bugfix release...

welp, this fix does more bad than good if you ask me.
I wrote with chatgpt a custom block code to display the promoted topics in a more compact manner, with poster avatar and a custom layout. After I got it working, I realised I can't actually promote the topics unless I have the promote topics option enabled in what to show on frontpage. Which of course, would lead to duplicate and unwated display of content. The promoted stuff can exist regardless if I choose the builtin option to display them, like in this example with the custom code.
Would you please consider fixing this again, maybe offering an option to display the promote button on topics that does not depend on any feture being enabled or not. Thanks
#7
Support / Re: Typing fast in the shoutbo...
Last post by sgm09 - April 27, 2025, 08:33:38 AM
Well, I had luck with chatgpt/claude developing two small mods for me that actually worked. Might try that route if nothing else happens :P

There's two things that need fixing. The charachter loss on typing when the ajax call is done, and the scroll reset to the end of the chat at the same ajax call, when someone is doing a scroll to chat history in the box.
#8
German / Re: Deutsche Sprachdateien (Do...
Last post by @rjen - April 25, 2025, 03:34:13 PM
By the way... you are a few version behind  8)
#9
German / Re: Deutsche Sprachdateien (Do...
Last post by @rjen - April 25, 2025, 03:32:58 PM
That is possible, yet we have multiple languages to maintain, and creating installation packages for very language every time there is a new version is just a lot of work that I am not willing to put into it...

We have all translations in Crowdin: https://crowdin.com/project/tinyportal

There are now 11 languages available, meaning 11 packages to be made / updated every release...
#10
German / Re: Deutsche Sprachdateien (Do...
Last post by McFly - April 25, 2025, 01:50:59 PM
Ich habe da einen Vorschlag *hust*

Wie wäre es mit der Nutzung Paketmanagers ... mit der angehängten Datei! Ich war so frei.  ;)


I have a suggestion *cough*

How about using the package manager ... with the attached file! I was generous enough.  ;)

This website is proudly hosted on Crocweb Cloud Website Hosting.