https://twill.io logo
Join Discord
Powered by
# ❓questions
  • i

    ifox

    12/05/2022, 1:51 PM
    oh haha, makes more sense
  • e

    elkex

    12/05/2022, 1:52 PM
    If I return $data['downloads'] I should be able to address it in the frontend as $block->downloads or just $downloads?
  • i

    ifox

    12/05/2022, 1:53 PM
    Should be just
    $downloads
  • e

    elkex

    12/05/2022, 1:55 PM
    I would have expected that too, but it does not seem to recognise the variable.. I added App/Twill/Block namespace & folder structure..
  • i

    ifox

    12/05/2022, 1:56 PM
    which method are you returning it from?
  • i

    ifox

    12/05/2022, 1:56 PM
    is the class executed when rendering the block? could be a naming issue
  • e

    elkex

    12/05/2022, 1:56 PM
    Copy code
    <?php
    
    namespace App\Twill\Block;
    
    use A17\Twill\Models\File;
    use A17\Twill\Services\Blocks\Block;
    
    class RecentDownloads extends Block
    {
        public function getData(array $data, \A17\Twill\Models\Block $block): array
        {
            $data = parent::getData($data, $block);
    
            $data['downloads'][] = File::latest()->take(6)->get();
    
            return $data;
        }
    }
  • i

    ifox

    12/05/2022, 1:57 PM
    you can try to dd in there to see if it actually execute when rendering you block. What's the filename of your block?
    recent-downloads
    ?
  • e

    elkex

    12/05/2022, 1:58 PM
    RecentDownloads in the app folder and recent_downloads in frontend as mentioned in the docs..
  • i

    ifox

    12/05/2022, 1:58 PM
    yeah ok that should work
  • e

    elkex

    12/05/2022, 1:59 PM
    I added the file here
  • e

    elkex

    12/05/2022, 2:01 PM
    The block class does not seem to execute
  • i

    ifox

    12/05/2022, 2:03 PM
    how are you rendering blocks?
    renderBlocks
    ?
  • e

    elkex

    12/05/2022, 2:04 PM
    Copy code
    {!! $page->renderBlocks() !!}
  • i

    ifox

    12/05/2022, 2:12 PM
    is
    recent_downloads
    a repeater inside another block, or is it the block itself?
  • i

    ifox

    12/05/2022, 2:13 PM
    If it's the block itself and its form view file is named
    recent_downloads.blade.php
    , this should work. If not, we'll investigate
  • e

    elkex

    12/05/2022, 2:13 PM
    It's called inside a block_editor block
  • e

    elkex

    12/05/2022, 2:14 PM
    So that is a repeater I think
  • i

    ifox

    12/05/2022, 2:17 PM
    then you need a class for its parent block
  • i

    ifox

    12/05/2022, 2:18 PM
    but I'm confused by the fact that you don't know if it's a repeater or not. if it's a repeater within a block, you must have a repeater form field inside one of your block's form
  • i

    ifox

    12/05/2022, 2:19 PM
    Basically, is recent downloads a block you can add from the Add content drop-down, or is it something you can add within another block?
  • e

    elkex

    12/05/2022, 2:29 PM
    It's just a content block it seems, sorry
  • i

    ifox

    12/05/2022, 2:32 PM
    ok, np
  • i

    ifox

    12/05/2022, 2:32 PM
    we'll try to reproduce
  • e

    elkex

    12/05/2022, 2:52 PM
    The block is called within a block_editor block
    Copy code
    @formField('block_editor', [
            'label' => 'Page content',
            'blocks' => [ 'recent_downloads']
        ])
  • d

    DKC

    12/06/2022, 7:31 AM
    Hello, I have a question about slug. May I know in /views/partials/create.blade.php Can I have :translated="true" in the slug input?
    Copy code
    php
    @if ($permalink ?? true)
        <x-twill::input
            name="slug"
            :label="twillTrans('twill::lang.modal.permalink-field')"
            :translated="true"
            ref="permalink"
            :prefix="$permalinkPrefix ?? ''"
        />
    @endif
    I tried to change :translated to false, but will have buggy result.
  • h

    Hip-Hop

    12/06/2022, 9:04 AM
    Hello, Has anyone encountered this problem? There are two modules (company contacts and branches). Company contacts consist of blocks. In branches, I need to substitute one block of company contacts (1 block of contacts must be displayed on the branches page on the front). (I output data to the block through the class, if anything).
  • e

    elkex

    12/06/2022, 9:42 AM
    How can you get the current item id and the parent_id inside of a frontend controller with a repository connected to?
  • k

    kalle

    12/06/2022, 10:00 AM
    Are you talking about nested modules? Sharing some more info would not hurt.
  • e

    elkex

    12/06/2022, 10:09 AM
    Fixed it! 🙂 Nevermind..
1...433434435...484Latest