Template for Site creation fails when scheduled works from command prompt

I’ve got a .NET core application that run fine from a command prompt that creates SharePoint Sites and adds content types from templates. When I schedule it to run via Windows Scheduled Tasks with the same account it fails with the following error:

Error applying client template: The Provisioning Template URI “MyTemplate.xml” is not valid.

The “client template” is the site collection template

What would cause it to not run properly when scheduled?

8 – Template override doesn’t work

I am trying to develop a Drupal 8 module in which I have to override the html.html.twig template. The idea is that I do not want any of the default html.html.twig template returned instead I only want the custom template returned. I have been spending hours Google hunting and trying to make sense of the many examples and I have gotten myself totally confused.

What is happening is the content of my custom template are being displayed in the default html template so I am seeing the custom content inside the default html template rather than overriding the default content.

For the sake of getting this template override working I have simplified the module as much as possible and simply want to return the contents of a variable into a placeholder in the twig template. Once this override is working I can go back and add the code that will create the correct content to be output into a number of variables in the template.

What I do not understand is exactly how to I override the html.html.twig template.

My module is called unsw_blocks and in the unsw_blocks.module I have the following

function unsw_blocks_theme() {

$theme = (
'unsw_blocks' => (
     'variables' => ('test_var' => NULL),
    ),
);

return $theme;
}

In the Unsw_blocksController.php have the following

class Unsw_blocksController extends ControllerBase {

  public function unsw_blocks($name) {
  return (
    '#theme' => 'unsw_blocks',
    '#test_var' => $this->t('The variable called test_var simply passes this text itself to the theme template'),
  );
  }
}

In the custom modules templates directory I have unsw-blocks.html.twig which simply contains

<h1>Testing Template</h1>

<p>test_var: {{ test_var }}</p>

How to override html.html.twig template for my custom page? [closed]

How I can override html template for my custom page?

I need a different html template for my custom page. So I try suggestions hook alter, but it’s don’t work.

/**
 * Implements hook_theme_suggestions_HOOK_alter().
 */
function mymodule_search_theme_suggestions_html_alter(array &$suggestions, array $variables) {
  $current_path = Drupal::service('path.current')->getPath();
  if ($current_path == '/map') {
    $suggestions() = 'html__map';
  }
}

Template file is in:

mymodule/templates/html--map.html.twig

c# template method pattern design question

I’m currently in a situation where I have multiple derived class types(just one is shown in the example below) that need to apply some logic before and/or after calling a method implemented in a common base class. I have two scenarios below and was wondering what would be a downside and upside for each approach in this use case scenario? The client code will be calling the relevant classes as defined in the main stub. The template method design pattern that is presumably being followed correctly in scenario b seems to be more popular based on research, but from first glance the code for approach a looks to be more minimal.

Thank you.

Scenario A:

using System.IO;
using System;

interface IContract
{
  void Foo();
};

abstract class Base : IContract 
{
    protected void FooImpl()
    {
        Console.WriteLine("base work");
    }
    public abstract void Foo();
};

class Derived : Base
{
    public override void Foo()
    {
        Console.WriteLine("pre work derived");
        FooImpl();
        Console.WriteLine("post work derived");
    }
}

class Program
{
    static void Main()
    {
        IContract contract = new Derived();
        contract.Foo();
    }
}

Scenario B:

using System.IO;
using System;

interface IContract
{
  void Foo();
};

abstract class Base : IContract 
{
    protected abstract void PreFooHook();
    protected abstract void PostFooHook();

    public void Foo()
    {
        PreFooHook();
        Console.WriteLine("base work");
        PostFooHook();
    }
};

class Derived : Base
{
    protected override void PreFooHook()
    {
        Console.WriteLine("pre work derived");
    }
    
    protected override void PostFooHook()
    {
        Console.WriteLine("post work derived");
    }
}

class Program
{
    static void Main()
    {
        IContract contract = new Derived();
        contract.Foo();
    }
}

Desired Output:

pre work derived
base work
post work derived

SharePoint Online : Promoted State for Site page should be o but when i create site page using template it shows 2

Stack Exchange Network


Stack Exchange network consists of 176 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

About template hierarchy – WordPress Development Stack Exchange

The answer is simple:

  • /search/query/?category_name=general&post_type=custom is not a part of WordPress and has been added by a plugin/theme, you need to ask their support or inspect the code to find out

For everything else, if is_search() is true, then it’s a search archive. If is_search() is not true it is not a search archive.

Since all of those URLs have ?s= they are all searching for things, so they are all search archives.

We know this because it shows search.php, and because the body class is:

class="archive search search-results category category-maintenance category-39 logged-in admin-bar  customize-support"

You shouldn’t need to know the priority of template to know which template is currently loaded. WordPress shares this information openly if you built the theme correctly, debugging tools will tell you, and you can always put this is the search template at the top of search.php and see if the text appears.

8 – Custom form returns NULL in custom template

I have a couple things:

-A custom form

-A custom theme

-A custom module for this form

I am trying to get the custom form to display on a custom template which is in a custom theme.

structure for custom module called weeks:

weeks

-src

–Controller

—WeeksController.php

–Form

—FormWeeks.php

-weeks.info.yml

-weeks.install

-weeks.module

-weeks.routing.yml

this is what FormWeeks.php looks like

<?php

namespace DrupalweeksForm;
use DrupalCoreFormFormBase;
use DrupalCoreFormFormStateInterface;

class WeeksForm extends FormBase {
  /**
   * {@inheritdoc}
   */
  public function getFormId() {
    return 'weeks_form';
  }

  public function buildForm(array $form, FormStateInterface $form_state) {
    
    
    $form('#theme') = 'weeks_form';
    
    
    $form('deactivate') = array(
        '#type' => 'submit',
        '#value' => $this->t('Deactivate'),
        '#name' => 'deactivate',
    );
    $form('2_week_pause') = array(
    '#type' => 'submit',
    '#value' => $this->t('Pause for 2 weeks'),
    '#name' => 'pause'
    );
    $form('start_again_week_1') = array(
    '#type' => 'submit',
    '#title' => $this->t('Start again at week 1'),
    '#name' => 'restart_week_1',
    );
 
    return $form;
  }

   /**
   * {@inheritdoc}
   */
  public function submitForm(array &$form, FormStateInterface $form_state) {
    

     $action = $form_state->getTriggeringElement()('#name');
     $user = Drupal::currentUser();
     if($action == 'deactivate'){
        $user->set('field_52_weeks', $action);
        $user->save();
     }else if ($action == 'restart_week_1'){
        $user->set('field_current_week', 1);
        $user->save();
     } else if ($action == '2_week_pause'){
        $user->set('field_52_weeks', $action);
        $user->save();
     }
    }

    
  
}

This is what is in weeks.module

<?php
function weeks_theme($existing, $type, $theme, $path){
   
    
    return (
        'weeks_form' => (
            'render element' => 'form',
            'template' => 'html--52weeks',
            
        )
    );
    }
    

this is what weeks.routing.yml looks like

weeks.page:
  path: '/52weeks'
  defaults:
    _title: '52 weeks'
    _form: 'DrupalweeksFormWeeksForm'
  requirements:
    _permission: 'access content'


I have a twig file in themes/custom/mytheme/templates called html–52weeks.html.twig. This is whats in there:

{{ dump(form) }}

that ^^ returns null and I have no idea why. I’ve tried changing the $form(‘#theme’) = ‘mytheme’, in WeekForm.php, but this still doesnt work. What I want is for this form to be displayed when someone goes to the /52weeks url. The main problem is that the form does not get passed to the template

PHP wordpress – template part including not working

EDIT –

I have since tried a blank and new php file and accessing it the same way – that worked. So I am now unclear why the existing file does not load at all. There are no errors. Here is the code start of the template part I am getting:

<?php
   require_once WP_PLUGIN_DIR.'/themename/includes/file1.php';
   require_once WP_PLUGIN_DIR.'/themename/includes/file2.php';
   require_once WP_PLUGIN_DIR.'/themename/includes/file3.php';
     
   if(isset($_GET("ict"))){
       $id_category() = "'{$_GET("ict")}'";
       $variable1= new file3();

I am trying to include a partial template and have read up on how to do so.

<div class="row">
    <div class="col-md-12">
        <?php get_template_part('/partials/category.php');
        ?>
    </div>
</div> 

The file I have included the above code in is in the theme main. The partial is in a folder in the theme main called partials. When I use /partials/category.php I get a blank with no PHP error in the area of the page where the information should be.

If I dont use the / on front of partials I get an error.

I have also tried removing the / on the front and at the same time removing the .php at the end. Same result where there is no error and no output

What am I missing about getting the template part to display>?

Here is the blank space where this should display
enter image description here

magento2 – Magento 2 : shipped items not appearing in email template

{{layout handle="sales_email_order_shipment_items" shipment_id=$shipment_id order_id=$order_id}}

is used to render shipped items in email template but no items appear in email template.

I had also set “is_legacy” to 1 in email_template table.

Any thoughts, what can be the issue ?

I am using Magento/2.4 (Enterprise)

views – Template suggestion does not work for table in a custom block / Might there be a way around?

I created a block on pages of the “Author” content type that lists all the articles the author has contributed to in a table (via contextual filter). Now I want to customize the table layout. I already did this before in a similar case, where I show the table on a page, not in a block. There I get file name suggestions for the template inside HTML comments like that:

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_table__articles' -->
<!-- FILE NAME SUGGESTIONS:
   x views-view-table--articles.html.twig
   x views-view-table--articles.html.twig
   * views-view-table.html.twig
-->
<!-- BEGIN OUTPUT from 'themes/MYTHEMEFOLDER/templates/views/views-view-table--articles.html.twig' -->

But in my latest case, the table in a block, I only get this suggestion:

<!-- THEME DEBUG -->
<!-- THEME HOOK: 'views_view_table' -->
<!-- BEGIN OUTPUT from 'themes/MYPARENTTHEMEFOLDER/templates/views/views-view-table.html.twig' -->

Note that it outputs the template of my parent theme, not my actual theme.

I did some research and found this issue, which currently is not resolved and the proposed patch not included inside the Drupal code. Is this the reason I cannot create a custom template or is there something else I can do?

If not, how would I create that table of referenced articles on the author’s page?