Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    codemonkeynorth
    @codemonkeynorth
    Much gratitude to you!
    Atanas Angelov
    @atanas-dev
    Thank you for the positive feedback :)
    codemonkeynorth
    @codemonkeynorth
    Because I had to build it quickly I used global $post at the top of my blade files. This should work fine right? It seems to
    Normally I’d set up controllers and view composers
    And pass to the render view
    Atanas Angelov
    @atanas-dev
    Use the loop, don't use global $post
    codemonkeynorth
    @codemonkeynorth
    You know ... I’ve never used the loop. Even if my more complicated sites :S
    I came from timber I never learned vanilla WP!
    *in
    I will fix it up later with a controller probably. I’ve got no sub queries/posts in the page etc so assumed $post had the data I need.
    Again not normally my approach
    codemonkeynorth
    @codemonkeynorth
    (....to use global)
    Atanas Angelov
    @atanas-dev
    You don't really need a controller just for a simple post loop :)
    Arthos
    @taliesinpenbardd

    Thank you for the positive feedback :)

    I must admit that I never made any feedback, but I've already used WPEmerge theme (with blade) on a certain number of sites, with a lot of happiness... thanks @atanas-dev !

    Atanas Angelov
    @atanas-dev
    Thank you as well :)
    Lee Hilton
    @lhilton
    Hey all! I'm super impressed with WPEmerge. It does just enough, without looking like a pile of unmaintainable headaches (ahemsageahem)
    I'm updating a build script that sets up new projects for me, and I am trying to see if the new rebrand script can take parameters from the command line. Does anyone know if this is possible?
    Atanas Angelov
    @atanas-dev
    Hi @lhilton ,
    The rebrand script is minimal and does not take command line parameters. That being said, the rebrand script is contained entirely within your project so you can edit it as you please: https://github.com/htmlburger/wpemerge-theme/tree/master/resources/build/rebrand
    That being said, note that changing it may cause some conflicts when updating to a future version. You should be comfortable with resolving git conflicts or you can just make a copy of the command :)
    Lee Hilton
    @lhilton
    @atanas-dev Thank you for getting back to me. Seems straight forward enough. Cheers!
    Romain
    @Romaixn
    Hello all ! Is it better to make a controller to make an ajax call? Or is there another solution?
    And how to do that ? (make an ajax call and call it with js)
    codemonkeynorth
    @codemonkeynorth
    I believe ajax is still best done via admin-ajax.php isn't it?
    Romain
    @Romaixn
    Of course, but I see there is a directory named "Ajax" in Controllers (in starter theme). I thought it could be used to make Ajax requests
    codemonkeynorth
    @codemonkeynorth
    Ah yes maybe. I’d not checked
    codemonkeynorth
    @codemonkeynorth
    Use that to route to your controller method and then i guess just return a json encoded response
    echo json_encode(array("blablabla"=>$variable));
    }
    codemonkeynorth
    @codemonkeynorth
    // \MyApp::route()->get()->where( 'ajax', 'my-custom-ajax-action' )->handle( 'ExampleController@ajax' );
    @ajax wont be specifically required, its just the name of a method in controller
    Atanas Angelov
    @atanas-dev
    The example in the docs is pretty much all you need - you specify the ajax action and who it should apply to (authed vs unauthed users) then you return whatever you want to respond with (return MyApp::json( $my_data ) will automatically encode $my_data as a JSON response)
    codemonkeynorth
    @codemonkeynorth
    MyApp::json is what I was looking for thanks. Did not see it in the docs when I skimmed over
    2pi.pl
    @piotrk_twitter
    @atanas-dev What are the chances of releasing any time soon the add/blade-component-support@wpemerge-blade branch?
    Or is there any alternative to this great Blade feature?
    Atanas Angelov
    @atanas-dev
    Unfortunately it's going to be awhile before I can get to it.
    Romain
    @Romaixn
    Thanks for your replies ! I did the controller, but how can I call my ajax in JS ? Is the name of the action is 'my-custom-ajax-action' ? (for example if I use \MyApp::route()->get()->where( 'ajax', 'my-custom-ajax-action' )->handle( 'ExampleController@ajax' );)
    Romain
    @Romaixn
    My Controller always return me '0'
    codemonkeynorth
    @codemonkeynorth
    Set your params for authed/non-authed users
    // Match requests from any user:
    \App::route()->get()->where( 'ajax', 'my-ajax-action', true, true )->handle( $handler );
    What’s your js?
    Romain
    @Romaixn
    Yes I have that..
    My JS is simple :
    data = {
                'action': 'see-more-ajax-action',
                'query': loadmore_params.posts,
                'page': loadmore_params.current_page
            };
    
            $.ajax({
                url: loadmore_params.ajaxurl,
                type: "POST",
                data: data,
    I have a 200 status code but returned '0' in success function
    codemonkeynorth
    @codemonkeynorth
    what does loadmore_params.ajaxurl equate to?
    oh you're doing a POST... but your route is get().. either use route()->post()->.. or route()->any()->...
    Romain
    @Romaixn
    ooooh... my bad of course
    Indeed it's work, thanks a lot for that
    codemonkeynorth
    @codemonkeynorth
    @Romaixn no worries . I learned something. Whaf is your ajaxurl tho? Is it just pointing to wp-admin/admin-ajax.php ?
    Piotr
    @piotrku

    The situation is like this:
    I pass all front-end requests through WPEmerge - MyApp::route()->all() so when I invoke some regular page, a view wp-content\themes\my-theme\views\page.php is automatically displayed.

    I'm wondering how to achieve this:
    I like this route -> controller -> view schema, but I don't want to create routes for all standard WP URLs .
    I'd like to have some controller(s) in the middle to inject some data (variables) when needed to some of the standard-route-views.
    How can I create a controller that would be automatically invoked for those standard WP routes before (in this case the page.php) view is served?
    Should I use middleware for that? One method that would check what route is this and delegate handling of this request to some dedicated classes?

    Atanas Angelov
    @atanas-dev

    If you want to inject some data into a view regardless of how it is rendered you can use View Composers which do just that: https://docs.wpemerge.com/#/framework/views/view-composers

    There's an article on the subject that you may find useful as well - it uses outdated syntax but the concepts are the same: https://wpemerge.com/2019/01/24/view-composers-passing-data-and-staying-dry/

    Alexander
    @xenx-efy
    Hello. I noticed that if I register an image import '@images/progress.svg', it goes to the fonts folder, not the images. How can this be corrected? Or maybe I'm doing something wrong?