Custom Placement for Custom Thread Fields

frm

Well-known member
It would be nice if that "custom placement" was an option for custom thread fields. I believe that the below screenshot speaks volumes as to why we need custom placement.

204886

But, to those that it don't understand the above: It's not necessary have og:title as a visible item, before the message, after the message or within the thread status block. This is because og:title tells Facebook (and all other social networks) what your "title" is (and would not use your <title> tag).

Instead, the below, unnecessary, modification doesn't have to be made to custom_fields_macros (which may or may not be the most optimal way of doing things):
Code:
        <xf:if is="$fieldDefinition.hasValue({$set.{$fieldDefinition.field_id}}) AND $fieldDefinition.title != 'og:title'">
From
Code:
        <xf:if is="$fieldDefinition.hasValue({$set.{$fieldDefinition.field_id}})">

As you can see, with more custom fields needed to be hidden, more AND statements have to be added. As I customize more and more and add schema and other Open Graph statements, the hidden values need to be edited in the template one by one to hide it.

Please consider adding a "custom placement" to where $thread.custom_fields.threadOGTitle (and all other custom fields made this way) is the only way it can be called/seen in a thread for complete custom placement (in the above example, arg-title).
 
Upvote 30

Russ

Well-known member
We'd be able to do a lot of creative things with custom thread fields if we had custom placement. I'd love to see this in XF! I'm currently somewhat achieving it by simply removing "below message" in the templates and calling those custom fields manually, but the custom option would be great.
 

DragonByte Tech

Well-known member
This is already possible, kinda. Consider the following class extensions:

PHP:
<?php

namespace Your\Namespace\XF\Entity;

use XF\Mvc\Entity\Structure;

/**
 * Class ThreadField
 *
 * @package Your\Namespace\XF\Entity
 */
class ThreadField extends XFCP_ThreadField
{
    /**
     * @param Structure $structure
     *
     * @return Structure
     */
    public static function getStructure(Structure $structure)
    {
        $structure = parent::getStructure($structure);
        
        $structure->columns['display_group']['allowedValues'][] = 'custom_pos_1';
        $structure->columns['display_group']['allowedValues'][] = 'custom_pos_2';
        
        return $structure;
    }
}

PHP:
<?php

namespace Your\Namespace\XF\Repository;

/**
 * Class ThreadField
 *
 * @package Your\Namespace\XF\Repository
 */
class ThreadField extends XFCP_ThreadField
{
    /**
     * @return array
     */
    public function getDisplayGroups()
    {
        $displayGroups = parent::getDisplayGroups();
        $displayGroups['custom_pos_1'] = \XF::phrase('your_namespace_display_pos_custom_pos_1');
        $displayGroups['custom_pos_2'] = \XF::phrase('your_namespace_display_pos_custom_pos_2');
        
        return $displayGroups;
    }
}

That being said, there is some merit to having a "Hidden" option built in to XF, where the field could be manually called if desired, just not displayed in the thread itself.
 

frm

Well-known member
We'd be able to do a lot of creative things with custom thread fields if we had custom placement. I'd love to see this in XF! I'm currently somewhat achieving it by simply removing "below message" in the templates and calling those custom fields manually, but the custom option would be great.
This is how I'll most likely implement it if it's not included in a core update over editing in each individual one as provided in the OP example, except for top as opposed to bottom because I am making use of those in other nodes.

I'd love to understand what @DragonByte Tech posted to see if that pretty much gives me a radio box option of custom placement, but, that's over my head. 😔 Pretty sure it's the beginnings of an addon, which would be cool, but I still stand behind it being a core function due to quite a few (small) "addons" developed for XF are merely things that can be made of custom fields and template modifications.
 

Kevin

Well-known member
We'd be able to do a lot of creative things with custom thread fields if we had custom placement. I'd love to see this in XF! I'm currently somewhat achieving it by simply removing "below message" in the templates and calling those custom fields manually, but the custom option would be great.
Are you doing manual template edits for the placements or doing some template mods?
 

Russ

Well-known member
Are you doing manual template edits for the placements or doing some template mods?

Manual template edits help me keep track of things I've edited. If it's for your own personal use I'd suggest just editing the templates directly.

As for the suggestion. Siropu handles it nicely, you can create "custom positions" and it gives you the code to paste. It'd be nice if when choosing this custom position it would output the required code to place:

2FeZaqMpS2q0uS6jLPJ1kw.png
 

frm

Well-known member
As for the suggestion. Siropu handles it nicely, you can create "custom positions" and it gives you the code to paste. It'd be nice if when choosing this custom position it would output the required code to place:
But you could also expand on Schema data like a thread starting with custom fields. Not naming add ons or anything, but one could tremendously benefit by placing Schema data in various places of a formatted thread with custom fields if they were "invisible". The OP could be designed so much better with a movie poster to the left and all the details to the right in a nice format (Title a bit bigger), etc. Dunno how you could quite aggregate reviews without an add on (but, I think you can run a loop at the end of the forum node to total "stars"), though you can do individual reviews with replies.

But this would require an add on?? No. A little bit more complex template edits and Google might eat it up.

 
Last edited:
Top