modularization – What design pattern we call for a kind of general purpose template based editor supporting many development framework

I am halfway through developing a general purpose editing tools which once finished can be used to develop any application project as well as making a simple document file. I call it a general purpose rapid templating and editing system. As for now it is a cloud service. Have no yet any plan to convert it into a native application.

How does it works?

There is a middleware system where middle user may use to build a template that specifically supports a type of project or a document format. For example, they can build a template represent an application development project, a design project, a website framework, a content management system, or even a document format like HTML, PDF, office document, and etc. I’m also provide support for a programming language of my own to be included for more complex functionalities. A template can also be built derived and extended from a base template.

On the other end, end user who actually need the system may use it to create whatever kind of stuff they want as long as required template is there, already developed by middle user. For example let say they need to create an e-book in EPUB file format, the system will serve as an alternative EPUB editor specifically for files structuring or editing. They only need to choose a template, following the rules set for the template, provide all required details into a form, attach chapters HTMLs and image files, and put them all together into a project directory before submit it. System will compile it and generate an EPUB file. The same process goes to other projects or files.

It’s like modularizing a project development into two parts, templating and creating a project, allowing users to not doing much repeating programming task or no programming at all, as well as avoiding users from complex files structuring and installation. If you’ve learned about a Turing complete notation technique called Backus-Naur form which is used to build any programming language, yes I’ve made it capable of doing that too.

It is quite a useful tool at least for me. That makes me wonder. I was looking everywhere for something similar to what I am building in hope it was already exists so no need for me to reinvent it. But so far I’ve found nothing similar perhaps because I don’t know what terms to use to search for it. So actually I just want to know whether I’m building something new, or something already exists and wasting time reinvent it. What terms we use to search for it? What’s it called?. Any examples?. If no one ever built it before, then why is that?

magento2 – Magento 2 – override knockoutjs template located in base folder

I need to change the value of the maxinput field in the knockoutjs template vendormagentomodule-uiviewbasewebtemplatesformelementinput.html so I have to replace the template with my own template loaded from my module appcodeCompanyBaseviewbasewebtemplatesformelementinput.html.

So I created a requirejs-config.js file in my module and tried to override the original knockoutjs file:

appcodeCompanyBaseviewfrontendrequirejs-config.js:

var config = {
    map: {
        '*': {
            'Magento_Ui/templates/form/element/input':'Company_Base/templates/form/element/input'
        }
    }
};

…then I cleared the cache, but it is still loading the original template instead of mine.

theming – How to count number of published nodes of a specific content type in twig template?

I’m looking for a way to achieve this in my Twig file; if the number of published entities of a content type ‘promotions’ is at least one, a certain entity should be displayed in a content type Shop. I’m trying to show a banner only if there is at least one published promotion entity.

I could use some help with the if-function. I’ve written it down with I’m trying to do.

if(published promotion entities > 0){
{{ drupal_entity('node', 2668) }}
}

Any ideas to get me going? Thanks!

magento2 – show email template available under marketing email template

i want to load email template from a custom admin grid when admi clicks on edit option my custom admin grid and then he can select email template form here only. is there any idea how to do it, i need suggestion

    protected function _prepareForm()
            {
                $model = $this->_coreRegistry->registry('current_netsmartz_dynamictemplate_items');
                /** @var MagentoFrameworkDataForm $form */
                $form = $this->_formFactory->create();
                $form->setHtmlIdPrefix('item_');
                $fieldset = $form->addFieldset('base_fieldset', ('legend' => __('Item Information')));
                if ($model->getId()) {
                    $fieldset->addField('id', 'hidden', ('name' => 'id'));
                }
   $fieldset->addField(


// i want to fetch email template here

        
 );
                
                
                $form->setValues($model->getData());
                $this->setForm($form);
                return parent::_prepareForm();
            }

thankss

wp query – Create a page template for “top rated posts” but show full content and not just a list

Sorry upfront if I’m not explaining this clearly. I’m using WP-PostRatings and it has this function:

<?php if (function_exists('get_most_rated')): ?>
    <ul>
        <?php get_most_rated(); ?>
    </ul>
<?php endif; ?>

Throwing that code in a template page shows a linked list of the top posts by user ratings but it’s not showing the full content of each post which is what I want. I believe I need to tap into the loop or create a custom query for this function?

For example, I made a custom page template to show a list of all my posts but doing this with a plugin’s function is where I get lost. How do I wrap the following page template in with this get_most_rated(); function so it uses the WP-PostRatings function and displays the top rated post as full content?

<?php
  // set up or arguments for our custom query
  $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
  $query_args = array(
    'post_type' => 'post',
    'post_status'=>'publish',
    'posts_per_page' => 11,
    'paged' => $paged
  );
  // create a new instance of WP_Query
  $the_query = new WP_Query( $query_args );
?>

<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('group post-standard'); ?>>
    <div class="post-inner">
        <div class="post-thumbnail">
            <a href="<?php the_permalink(); ?>">
                <?php if ( has_post_thumbnail() ): ?>
                    <?php hu_the_post_thumbnail('beatpost-thumb'); ?>
                <?php elseif ( hu_is_checked('placeholder') ): ?>
                    <img src="<?php echo get_template_directory_uri(); ?>/assets/front/img/thumb-standard.png" alt="<?php the_title(); ?>" />
                <?php endif; ?>
                <?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-play"></i></span>'; ?>
                <?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-volume-up"></i></span>'; ?>
                <?php if ( is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-star"></i></span>'; ?>
            </a>
            <?php if ( comments_open() && ( hu_is_checked( 'comment-count' ) ) ): ?>
                <a class="post-comments" href="<?php comments_link(); ?>"><span><i class="fa fa-comments-o"></i><?php comments_number( '0', '1', '%' ); ?></span></a>
            <?php endif; ?>
        </div><!--/.post-thumbnail-->
        
        <div class="post-content">
        
            <h2 class="post-title entry-title">
                <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
            </h2><!--/.post-title-->
            
            <div class="beat-share"><span class="beat-social-button-fb"><a href="javascript:void(0);" onclick="PopupCenter('https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&amp;t=<?php the_title(); ?>', 'myPop1',531,545);"><i class="fa fa-facebook"></i></a></span> <span class="beat-social-button-twit"><a href="javascript:void(0);" onclick="PopupCenter('https://twitter.com/share?text=<?php the_title();?>&gt;&gt; Buy and Download Hundreds of Rap Beats&amp;via=RockItPro&amp;hashtags=buyrapbeats&amp;url=<?php the_permalink();?>', 'myPop1',539,253);"><i class="fa fa-twitter"></i></a></span></div>
            
            <div class="entry excerpt"><?php the_content(); ?></div>
            
            <div class="post-meta group">
                <p class="post-byline" style="display:none;"><span class="vcard author"><span class="fn"><a href="https://www.rockitpro.com/author/Sho-Down/" title="Posts by Sho-Down" rel="author">Sho-Down</a></span></span></p><p class="post-category"><?php the_category(', '); ?></p><p class="post-date date updated published"><i class="fa fa-angle-double-right"></i><?php the_time('m/d/Y'); ?><span class="anglemobile"><i class="fa fa-angle-double-right"></i></span></p><p class="cat-posts"><a href="<?php comments_link(); ?>"><span><i class="fa fa-comments-o"></i> <?php comments_number( '0', '1', '%' ); ?><span class="comment-text"> Comments</span></span></a></p>
            </div><!--/.post-meta-->
        </div><!--/.post-content-->
    </div><!--/.post-inner-->
</article><!--/.post-->

<?php endwhile; ?>

<div id="navigation">
<?php $big = 999999999; // need an unlikely integer
echo paginate_links( array(
    'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
    'format' => '?paged=%#%',
    'current' => max( 1, get_query_var('paged') ),
    'mid_size' => 2,
    'end_size' => 1,
    'total' => $the_query->max_num_pages
) ); ?>
</div>

<?php else: ?>
  <article>
    <h1>Sorry...</h1>
    <p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
  </article>
<?php endif; ?>

    </div><!--/.hu-pad-->
</section><!--/.content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Custom taxonomy template shows different content if there are children

I am trying to create a template for my custom post type (products) custom taxonomy (product_category) that will show sub categories if there are any and but if there aren’t, then it should list the products.

As an example

categories:

category1
category2
-sub-category1
-sub-catetory2
category3

so if the url is loaded (/product_category/category1) then it will list the products in that category.

However if (/product_category/category2) is loaded, then it will show the names “subcategory1” and “subcategory2” but no actual products.

Here is what I came up with so far, but it feels “hacky” is there a better way to do this?

<?php
get_header(); ?>

    <div id="primary">
        <main id="main">
            <?php

            do_action( 'generate_before_main_content' );

            if ( have_posts() ) :

                $term = get_queried_object();
                $term_id = $term->term_id;
                $taxonomy_name = $term->taxonomy;

                $termchildren = get_term_children( $term_id, $taxonomy_name );
                if ( $termchildren  ) {
                        //there are kids...just show the children categories.
                                            // we have kids...just show the terms.
                   echo '<ul>';
                   foreach ( $termchildren as $child ) {
                       $term = get_term_by( 'id', $child, $taxonomy_name );
                       echo '<li><a href="' . get_term_link( $child, $taxonomy_name ) . '">' . $term->name . '</a></li>';
                }
                   echo '</ul>';
                } else { 
                    //no kids...right on to the products.
                    echo '<div class="productCategories grid">';
                        while ( have_posts() ) : the_post();
                            ?>
                            <div class="product_cat">
                                <a href="<?php the_permalink();?>">
                                    <?php the_post_thumbnail('small');?>
                                    <h2><?php the_title();?></h2>
                                </a>
                            </div>
                            <?php
                        endwhile;
                    echo '</div>';
                }
            else :
                get_template_part( 'no-results', 'archive' );
            endif;
            ?>
        </main><!-- #main -->
    </div><!-- #primary -->

    <?php
get_footer();

8 – Webform Status in Webform Submission Twig Template

I’d like to use the current open/closed status of a webform in a conditional on the webform-submission-information.html.twig. There is a “webform” variable available to use in the template_preprocess_webform_submission_information function, but all that seems to do is print a link to the webform. When I try to use the usual methods that I’d usually use on a webform object, I just get WSOD. Something tells me that variable isn’t actually an object.

For example, perhaps I could get the webform id and use that to figure out the status of the webform…

$form = $vars('webform')('details')('nid')('#value');

Also, is there a resource for figuring out the pathing to the API is for the Webform? The documentation exists on the Drupal site certainly, but it’d be a lot easier if there was some kind of resource that gave us the path to all these data endpoints. As it stands, even if I figured out the correct function for extracting the webform’s ID, I wouldn’t have any clue how to find the status (open/closed) endpoint. There are some old d7 articles and issues out there, but it’d be nice if we didn’t have to rely on issues and, instead, if there was intuitive documentation.

theming – Webform Status in Twig Template

I’d like to use the current open/closed status of a webform in a conditional on the webform-submission-information.html.twig. There is a “webform” variable available to use in the template_preprocess_webform_submission_information function, but all that seems to do is print a link to the webform. When I try to use the usual methods that I’d usually use on a webform object, I just get wsod. Something tells me that variable isn’t actually an object.

For example, perhaps I could get the webform id and use that to figure out the status of the webform…

$form = $vars(‘webform’)(‘details’)(‘nid’)(‘#value’);

Also, is there a resource for figuring out the pathing to the API is for the Webform? The documentation exists on the Drupal site certainly, but it’d be a lot easier if there was some kind of resource that gave us the path to all these data endpoints. As it stands, even if I figured out the correct function for extracting the webform’s ID, I wouldn’t have any clue how to find the status (open/closed) endpoint. There are some old d7 articles and issues out there, but it’d be nice if we didn’t have to rely on issues and, instead, if there was intuitive documentation.

theming – Override of commerce-order-receipt.html.twig template not working?

My theme is using Bootstrap barrio theme (bootstrap_barrio) as a base theme. I’m trying to override Drupal commerce template modules/contrib/commerce/modules/order/templates/commerce-order-receipt.html.twig and it’s not working for me. Even I copied that file to drupal/web/themes/my_theme/templates ,cleared the cache, Commerce is still using original template file from commerce module.

What puzzles me is that base Barrio theme also has that template and it’s also not used?!?

Do I have to set somewhere what theme should be used for email templates or something? Overriding other modules templates (including commerce templates) works fine. Documentation says “The email can be customized by overriding the Twig template in your theme just as you would any other template”.

Custom Business Powerpoint or word document template to be used in powerpoint and word in O365 Sharepoint

My requirement is when a user clicks to open a PowerPoint or Word document from a SharePoint document library. It should display all the business templates of my organization.

Whenever I create a document library those templates should reside inside the PowerPoint or Word document. It should be applicable on any sites created under that O365 SharePoint.

Example: Any SharePoint site → Document library → Click New → PowerPoint document should display my custom business template.

Note: If I add any new template or change an existing business template that too should be populated. Could you please assist me how to achieve it?