Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter tyeshutty

    (@tyeshutty)

    Thanks for the reply @dilip2615 ,

    Using your code, I got the error Module not found: Error: Can’t resolve ‘style-loader’

    So I installed npm install style-loader –save

    When I ran it again, I got no errors, but the screen.css file wasn’t generated (only screen.asset.php was generated).

    I have webpack 5.95.0, @wordpress/scripts 30.4.0, and style-loader 4.0.0

    This is the entire webpack.config.js

    const defaultConfig = require('@wordpress/scripts/config/webpack.config');

    const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');

    const path = require('path');

    module.exports = {

    ...defaultConfig,

    ...{

    entry: {

    'css/screen': path.resolve(process.cwd(), 'resources/scss', 'screen.scss')

    },

    plugins: [

    ...defaultConfig.plugins,

    new RemoveEmptyScriptsPlugin({

    stage: RemoveEmptyScriptsPlugin.STAGE_AFTER_PROCESS_PLUGINS

    })],

    module: {

    rules: [{

    test: /\.scss$/i, use: ["style-loader", { loader: "css-loader", options: { url: false, }, }, "sass-loader"],

    },],

    }

    }

    };
    Thread Starter tyeshutty

    (@tyeshutty)

    Thanks, field() does work without the orderby, no worries, I was overthinking it.

    Thread Starter tyeshutty

    (@tyeshutty)

    Thanks! Here’s the code I used to retrieve the “pages” field:

    $image_ids = get_post_meta($post_id, '_pods_pages', true);
    $images = pods()->field('pages', array('orderby' => 'FIELD(ID, ' . implode(',', $image_ids) . ')'));
    Thread Starter tyeshutty

    (@tyeshutty)

    Hi Scott, please share the location where the file order is saved in the db.

    Thread Starter tyeshutty

    (@tyeshutty)

    I wrote this plugin code to accomplish the task of saving the order to a “pages_order” hidden plaintext field:

    function enqueue_my_scripts()
    {
    wp_register_script('PodsHelper', plugin_dir_url(__FILE__) . 'pods-helper.js', array(), filemtime(plugin_dir_path(__FILE__) . 'pods-helper.js'), true);
    wp_enqueue_script('PodsHelper');
    }

    global $pagenow;
    if (!empty($pagenow) && 'post.php' === $pagenow) {
    add_action('admin_enqueue_scripts', __NAMESPACE__ . '\enqueue_my_scripts');
    }
    function initObserver() {
    const observer = new MutationObserver(mutations => {
    let files = document.querySelectorAll('.pods-dfv-list-item');
    let order = [];
    for (const file of files) {
    let hiddenInput = file.querySelector('input[type="hidden"]');
    if (!hiddenInput) {
    order = [];
    break;
    } else {
    order.push(hiddenInput.value);
    }
    }
    let orderString = '[' + order.join(',') + ']';
    let orderInput = document.querySelector('#pods-form-ui-pods-meta-pages-order');
    orderInput.value = orderString;
    });

    observer.observe(document.querySelector('#pods-meta-more-fields'), {
    childList: true,
    subtree: true
    });
    }

    if (document.readyState === 'complete') {
    initObserver();
    } else {
    window.addEventListener('load', function () {
    initObserver();
    })
    }
Viewing 5 replies - 1 through 5 (of 5 total)