Skip to content

Instantly share code, notes, and snippets.

View cherrykoda's full-sized avatar
🦊
Crafting the Crafts

Shawna O'Neal cherrykoda

🦊
Crafting the Crafts
View GitHub Profile
{# This example shows table appends for creating a student roster #}
{% for row in registrations %}
{% if row['courseId'] == courseId %}
{% set courseRegistrations = courseRegistrations + 1 %}
<div class="form__row {{ registrations|length ? 'student' }}">
<div class="form__field col-ml-5 col-sm-12">
<input type="hidden" name="fields[checkoutAttendeeList][{{tableOffset}}][sessionId]" value={{ courseEvents|length ? courseEvents.one.id : null }}> {# Updates when date is selected #}
<input type="hidden" name="fields[checkoutAttendeeList][{{tableOffset}}][courseId]" value="{{ courseId }}"> {# Updates when date is selected #}
<label class="required form-label">
@cherrykoda
cherrykoda / ax-craft-controller.php
Created March 22, 2021 01:52
AX Craft Controller
<?php
/**
* Microsoft AX module for Craft CMS 3.x
*
* Integrates Craft CMS 3.X with an instance of Microsoft Dynamics AX
*
* @link dodgyco.de
* @copyright Copyright (c) 2021 Shawna O'Neal
*/
@cherrykoda
cherrykoda / ax-curl.php
Created March 22, 2021 01:13
Curl Call for AX
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://domain.com:8201/XXXXX/SERVICENAME/xppservice.svc");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, "DOMAIN\username" . ":" . "password");
$headers = array();
$headers[] = "Content-Type: text/xml; charset=\"utf-8\"";
$headers[] = "Soapaction:http://schemas.microsoft.com/dynamics/2008/01/services/SalesOrderService/create";
@cherrykoda
cherrykoda / ax-data.php
Last active March 22, 2021 01:01
AX Order XML using Sabre
$ns1url = 'http://schemas.xmlsoap.org/soap/envelope/';
$ns2url = 'http://schemas.microsoft.com/dynamics/2008/01/services';
$ns3url = 'http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder';
// Sabre needs the urls above to include as namespace urls,
// For indicating namespacing per node, we need the curly brackets added.
$ns1 = '{' . $ns1url . '}';
$ns2 = '{' . $ns2url . '}';
$ns3 = '{' . $ns3url . '}';
@cherrykoda
cherrykoda / ax-input.xml
Last active March 22, 2021 02:04
Working AX XML
<?xml version="1.0" encoding="UTF-8"?>
<x:Envelope
xmlns:x="http://schemas.xmlsoap.org/soap/envelope/">
<x:Header/>
<x:Body>
<SalesOrderServiceCreateRequest
xmlns="http://schemas.microsoft.com/dynamics/2008/01/services">
<SalesOrder
xmlns="http://schemas.microsoft.com/dynamics/2008/01/documents/SalesOrder">
<SalesTable class="entity">
@cherrykoda
cherrykoda / sabre-verbose.php
Created March 20, 2021 01:09
Sabre XML Verbose Naming
$ns = '{http://www.w3.org/2005/Atom}';
$service->namespaceMap['http://www.w3.org/2005/Atom'] = '';
$service->write($ns . 'feed', [
$ns . 'title' => 'Example Feed',
[
'name' => $ns . 'link',
'attributes' => ['href' => 'http://example.org/']
],
$ns . 'updated' => '2003-12-13T18:30:02Z',
$ns = '{http://example.org/}';
$service->write('{http://example.org/}root',[
$ns . 'title' => 'Foundation',
$ns . 'author' => [
$ns . 'firstname' => 'Isaac',
$ns . 'lastname' => 'Asimov',
]
]);
@cherrykoda
cherrykoda / _overview.twig
Created July 13, 2020 14:10
[Medium] Macros v. Partials - State Sport Articles
{% set sportArticles = craft.entries.section('articles').relatedTo(['and',
{ element : state },
{ element : sport }
]) %}
{# Set Popular Articles #}
{% do craft.views_work.sortPopular(sportArticles, 'month') %}
{% set popularArticles = sportArticles.limit(6).all %}
<div class="hero" {% if sport %}style="background: url({{ sport.sportBackground.one.url('sportBg') }}) center center no-repeat; background-size: cover;"{% endif %}>
@cherrykoda
cherrykoda / _popular-now.twig
Created July 13, 2020 14:03
[Medium] Macros v. Partials - Popular Now
@cherrykoda
cherrykoda / _excerpt.twig
Last active July 13, 2020 13:50
[Medium] Macros v. Partials - Solutions Excerpt
<main>
<section id="overview">
<div class="container">
<div class="intro">
{% if entry.overviewIcon and entry.overviewIcon.one %}
<div class="icon">
{% set img = entry.overviewIcon.one %}
<img src="{{ img.getUrl('iconMedium') }}" alt="{{ img.imageAltText|length ? img.imageAltText : img.title }}">
</div>
{% endif %}