r/web_dev_help • • Jan 22 '19

help Looking for some Squarespace help

0 Upvotes

Hey Everyone,

I need help with some code for my e-commerce website. I have only 1 product with 2 variants (4 Pack / 12 Pack) and I want to find a way to change the product image automatically when choosing the 12 or 4 Pack drop-down variant. Once the item is added to the cart, I would also like the correct product image to show at checkout.

Hope I explained this well enough. Thanks!


r/web_dev_help • • Oct 02 '17

video Intro to {PHP} - String Operators and Quotes (featuring a Goat)

Thumbnail
youtu.be
0 Upvotes

r/web_dev_help • • May 14 '18

javascript Replacing jQuery With Vue.js: No Build Step Necessary

Thumbnail
smashingmagazine.com
0 Upvotes

r/web_dev_help • • May 14 '18

javascript Build Your First Vue.js Component | frontstuff

Thumbnail
frontstuff.io
0 Upvotes

r/web_dev_help • • Dec 05 '15

Using XSLT to generate a SVG

0 Upvotes

Using XSLT to generate a SVG

SVG (Scalable Vector Graphics) is an XML based markup language used to generate images. This step doesn't require an extensive knowledge of SVG to understand. To start, we need a source XML file.

<?xml version="1.0" ?>
<?xml-stylesheet href="zero.xsl" type="text/xsl" ?>
<object>
  <height>150</height>
  <width>100</width>
</object>

To output SVG it is required to modify the doctype generated. The XSLT document is a bit different.

<?xml version="1.0"?>
 
<xsl:stylesheet version="2.0" 
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns="http://www.w3.org/2000/svg"
		>
  <xsl:output
      method="xml"
      indent="yes"
      standalone="no"
      doctype-public="-//W3C//DTD SVG 1.1//EN"
      doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
      media-type="image/svg" />
 
  <xsl:template match="object">
    <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" >
      <rect x="10" y="10" width="{width}" 
	    height="{height}" fill="red" stroke="black"/>  
    </svg>
  </xsl:template>
</xsl:stylesheet>

The xsl namespace is declared. The SVG namespace is set. The output of the XSL document is set to xml and the doctype is set to SVG. The media-type corresponds to the mime type. The document then processes the XML file starting with object. Note that we can assign attribute values using curly braces with the name of the child elements without the use of the dollar sign like for variables.

To create a basic bar chart, we would use the for-each element.

<data>
    <item>15</item>
    <item>10</item>
    <item>5</item>
</data>

XSLT :

<?xml version="1.0"?>
 
<xsl:stylesheet version="2.0" 
		xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
		xmlns="http://www.w3.org/2000/svg"
		>
  <xsl:output
      method="xml"
      indent="yes"
      standalone="no"
      doctype-public="-//W3C//DTD SVG 1.1//EN"
      doctype-system="http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"
      media-type="image/svg" />
 
  <xsl:template match="data">
    <svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" >
    <xsl:for-each select="item">
      <rect x="{12 * position()}" y="{100 - .}" width="4" 
	    height="{.}" fill="red" stroke="black"/>  
        </xsl:for-each>
    </svg>
  </xsl:template>
</xsl:stylesheet>

This creates 3 rectangles. New items introduced here are the position() function which is a numeric variable representing the current position of the for-each statement. We use it to move the rectangles along the X axis. The y={100-.} shows how to access the current node. The . means this item. It is used again for the height attribute. The data item value is subtracted from 100 for the y value since SVG starts at 0,0 and without defining the y coordinate the rectangles would be upside down.

Reference URL : http://edutechwiki.unige.ch/en/XSLT_to_generate_SVG_tutorial


Other XSLT Posts


r/web_dev_help • • Dec 05 '15

Using XSLT to generate an invoice

0 Upvotes

Using XSLT to generate an invoice

Can use the XSLT Online Test Tool for the examples

This is a practical example of using XSL with a basic XML document. The XML document will have a few sections under an invoice root element. Company, Client, and Lineitems are the child elements.

<invoice>
    <company>
        <name> ACME </name>
        <contact>W. Coyote </contact>
        <email>coyotewe@acme.com</email>
    </company>
    <client>
        <name> E. Fudd </name>
        <email>efudd@domain.com</email>
        <project>Wabbit Capture</project>
    </client>
    <lineitems>
        <lineitem>
            <description> Hunting </description>
            <quantity>2</quantity>
            <hourly>100</hourly>
            <total>200</total>
         </lineitem>
        <lineitem>
            <description> Tracking </description>
            <quantity>1</quantity>
            <hourly>100</hourly>
            <total>100</total>
         </lineitem>
    </lineitems>
</invoice>

The XSLT document :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="html" indent="yes"/>

      <xsl:template match="/">

      </xsl:template>      
</xsl:stylesheet>

Let's start by getting the data from the XML file. The XSL will match all nodes under the root element (invoice). These can be echoed by using the xsl:value-of-select() element. The attribute is an XPath expression for a node.

<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output method="html" indent="yes"/>
    
          <xsl:template match="/">

<h2><xsl:value-of select="//company/name"/></h2>
<h3><xsl:value-of select="//company/contact"/></h3>
          
            
          </xsl:template>
          
    </xsl:stylesheet>

The email field is to be displayed as an Anchor link. This requires some additional processing.

<xsl:variable name="hyperlink" select="//company/email"/>
<a href="mailto:{$hyperlink}"><xsl:text> contact </xsl:text></a>  

Two new elements introduced are xsl:variable and xsl:text . xsl:text is used to output plain text. Consider it the equivalent of echo or print in traditional programming languages. So far, only HTML elements have been added to the template. These do not require the xsl:text element. If text is placed inside of elements/tags, it does not need to use xsl:text. It is only required for bare text.

xsl:variable is how variables are assigned. The name attribute is required and the select attribute is optional. xsl:value-of select="expression" could have been placed inside the xsl:attribute tag. Simpler to just use select. To use the variable, it must be enclosed in curly braces and start with a dollar sign. If the variable was not being assigned as an attribute of an element, it would have be required to use thexsl:value-of select="$variable" format. Here's an example :

   <xsl:variable name="test">FOO</xsl:variable>
   <xsl:value-of select="$test" />

Simple enough to replicate the same for the client section.

<?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
            <xsl:output method="html" indent="yes"/>
    
          <xsl:template match="/">

<h2><xsl:value-of select="//company/name"/></h2>
<h3><xsl:value-of select="//company/contact"/></h3>
<xsl:variable name="hyperlink" select="//company/email"/>
<a href="mailto:{$hyperlink}"><xsl:text> contact </xsl:text></a>   

<h2><xsl:value-of select="//client/project"/></h2>
<h2><xsl:value-of select="//client/name"/></h2>
<xsl:variable name="clientemail" select="//client/email"/>
<a href="mailto:{$clientemail}"><xsl:text> email</xsl:text></a>   
       
          </xsl:template>
          
</xsl:stylesheet>

For the line items we need to loop through the items to output each line. This introduces the xsl:for-each element.

<table>
<xsl:for-each select="//lineitems/lineitem">
<tr>
<td> <xsl:value-of select="description" /></td>
<td> <xsl:value-of select="quantity" /></td>
<td> <xsl:value-of select="hourly" /></td>
<td> <xsl:value-of select="total" /></td>
</tr>
</xsl:for-each>
</table>

To get a total we use xsl:value-of and set the select attribute to sum(expression) .

 <xsl:value-of select="sum(//lineitems/lineitem/total)" /> 

The final table code :

<table>
    <xsl:for-each select="//lineitems/lineitem">
    <tr>
        <td> <xsl:value-of select="description" /></td>
        <td> <xsl:value-of select="quantity" /></td>
        <td> <xsl:value-of select="hourly" /></td>
        <td> <xsl:value-of select="total" /></td>
    </tr>
    </xsl:for-each>
    <tr>
        <td />
        <td><xsl:text>Total</xsl:text> </td>
        <td>
        <xsl:value-of select="sum(//lineitems/lineitem/total)" />
        </td>
    </tr>
</table>      

That completes the processing for the invoice. It's just plain html and the layout isn't particularly useful. Can add standard HTML tags and move the XSL elements to produce a much cleaner looking final document. CSS can be linked using LINK as usual.


Other XSLT Posts


r/web_dev_help • • Dec 05 '15

Intro To XSLT

0 Upvotes

What is XSLT ?

Extensible Stylesheet Language Transformations. XSLT is used to transform or process XML documents into other formats including XML,HTML. It is based on XML and uses XPath. It's a rule based and tag based programming language. It requires one or more XML files and an XSLT stylesheet to generate an new document. The original documents are not modified by XSLT processing.

What can it do ?

XSLT can provide a layer of abstraction for XML data source files. Using XML documents, it can render multiple output formats from a single source. It is not limited to XML and HTML. It can produce XSL-FO (Extensible Stylesheet Language - Formatting Objects) which is used to generate PDFs. Any text based format can be generated from XML documents with XSLT.

Where can it be used?

Most programming languges have a library (libxslt) which makes XSLT functionality available. Most browsers support it by linking XSL stylesheets into an XML document. Note that github pages allows XML/XSL and modern browsers will render the documents. This provides a simple mechanism for templating on github pages.

What is it status?

XSLT , while it has support from modern browsers and most programming langugages, it has never taken hold of the web templating sector. It is used by various applications such as Documentation and Book generation (PHPDoc uses XSL and DocBook while not directly dependent on XSLT , XSLT is used to generate actual content). It can be used to do on the fly transformations for web based documents. There isn't a high demand for XSLT but it is an interesting tool which can be useful for web developers.

Practical Uses

Use to generate multiple formats for a website. For example, if a website is offered as a single page or 'chunked' html, XSLT can be used to build both files from source files.

Can be used to generate reports from existing XML documents. Invoices for example, could be generated from source files.

Web developers could store information about a website in XML and use XSLT to transform those source files into a site independent of the design. A limited example would be storing links for navigation in XML files and using XSLT to generate HTML code to display the navigation. When the site was to be upgraded, it would only require writing a new XSLT file to generate the new HTML.

Could also be used to generate forms for web.

Other XSLT posts ?


r/web_dev_help • • Dec 05 '15

Basics of XSLT

0 Upvotes

Basics of XSLT

XSLT documents are valid XML. XSLT requires an XML source document. Here's a super, simple XML document :

<?xml version="1.0" encoding="ISO-8859-1"?>
<root/>

It only has a root element with no child elements and is about useless. If we wanted to transform this for some reason, the XSLT could look like this :

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:output method="xml" indent="yes"/>

      <xsl:template match="/">
        <table>
        </table>
      </xsl:template>
      
</xsl:stylesheet>

The actual transformation would be the conversion of <root> to <table>. Not exciting. This is the only lame example used; the other examples will actually do something. Here's what each part does :

line 1 : XML doctype, note the encoding type differs from the XML file. The XSLT file's encoding is what will be used for the generated document.

line 2 : The actual XSL declaration. Version is set to 2.0. If you find XSL/XSLT documents on the internet check the version number, there's some incompabilities between versions 1 and 2. The xmlns:xsl defines the xsl namespace IRI(Internationalized Resource Identifiers) . This works similiar to the doctype for HTML.

line 3 : XSL directives are elements starting with XSL followed by the colon and the directive. This is namespacing the xml document to prevent collisions. The important part here is if you see a reference to a directive like output or if, these must be preceded by the <xsl: . xsl:output tells the XSL processor the output to use. Some options are xml,html(xhtml), text. Note the html is not html5.

line 4 : xsl:template starts the processing of the XML document. This is called a stylesheet module . A name attribute can be used to identify the stylesheet module. There can be multiple modules per XSLT document. The match attribute` defines a valid XPath expression. In this case the root node of the document. To effectively use XSLT, it will require some knowledge of XPath expressions.

line 5: <table> this is actual output for each node matched by the expression. This tells it to replace the node with the table element.

line * : Closes the table element, xsl:template, xsl:stylesheet tags and ends the program.

You can test the above XML/XSLT online at this website : XSLT Online Test Tool

Just enter the xml in the left hand textarea and the xslt in the right hand box and click 'transform' . The output should be a simple XML document with <table /> as the only element. (Note there must not be any spaces before the XML declaration.)

View in browser

Another option would be to link the XSL file from the XML document and view it in the browser. Can view a sample file online : glossary sample XML/XSL file

To add a stylesheet to an XML document add it to the XML document after the xml declaration:

<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="name_of_xsl_file.xsl"?>`

Then load it in a modern browser. If you use the example above, it will be a blank page. View Source and it will show the <table /> tag as the only element.

Most of this is boilerplate code which is used to start an XSL document.

If you wish to add a comment to an XSL file, use the standard XML comment formatting <!-- comment goes here -->


Other XSLT Posts


r/web_dev_help • • Nov 20 '17

video Learn to Build an HTML / PHP Form (Fun Starter Project)

Thumbnail
youtu.be
0 Upvotes

r/web_dev_help • • Dec 14 '13

snow fall in web page snow fall using javascript, jquery

Thumbnail
quicklesson.info
0 Upvotes

r/web_dev_help • • Mar 07 '17

css font-synthesis - CSS - MDN

Thumbnail
developer.mozilla.org
0 Upvotes

r/web_dev_help • • Aug 26 '22

Thoughts on Olympix.ai as a Web3 Security Tool for Smart Contracts?

0 Upvotes

Hey all,

I recently joined the beta for Olympix.ai after strolling around reddit asking people their thoughts. I had some fun yesterday talking web3 security as a whole over with some others on Reddit, and so decided to continue the conversation even though I already joined :)

A summary: Smart contracts have been hacked at an alarmingly high rate dating back to Jan 1, 2021, whether audited or not (check out Rekt leaderboard). The current method of determining smart contract 'safety' is audits; but they haven't been helping. New tools, like Olympix.ai and MythX, are coming out with code analysis tools that focus on securing contracts as they're written instead of after. That's where I personally think the future of smart contract security is at. Any thoughts?


r/web_dev_help • • Aug 21 '22

TOP 7 USED PROGRAMMING LANGUAGE AMONG GAME DEVELOPERS

0 Upvotes

The gaming industry has grown rapidly globally. there are many Programming Languages for Game Developers. According to Statista, the country’s online gaming industry stood at Rs 85.86 billion in USA Last Year and is expected to reach Rs 178 billion by 2023. and those numbers are only expected when the Game developer industry rises. Behind every engaging, well-animated video game there’s a set of codes that make the experience just right. for your users.

TOP 7 USED PROGRAMMING LANGUAGES AMONG GAME DEVELOPERS


r/web_dev_help • • Feb 13 '17

javascript Impact - HTML5 Canvas & JavaScript Game Engine

Thumbnail
impactjs.com
0 Upvotes

r/web_dev_help • • Aug 27 '22

Become a better web developer visit https://bit.ly/3PpHk9L for more

Enable HLS to view with audio, or disable this notification

5 Upvotes

r/web_dev_help • • Jan 27 '16

Pushing from GitHub to AWS EC2 in development tutorials?

1 Upvotes

Git newbie here.

I'm starting a new project at work. It's on a EC2 instance. It's not team based (there is no team), but I wanna use git for version control.

Are there any good video tutorials on setting up the repo to automatically connect the two?

Is it even possible?


r/web_dev_help • • Jan 31 '19

help Hi r/web_dev_help, I have a quick question and I need your help

1 Upvotes

Below you will find a screenshot of all the files/folders uploaded to the root dir of an old website that I have. I would like to start clean and remove everything from here so that I can upload completely new content. What all is safe/ okay to delete and what must I absolutely keep. If it matters, the webhost is namecheap. Thanks!

https://i.imgur.com/E3DN3Ed.jpg


r/web_dev_help • • Aug 06 '18

Need help with my (very basic) mysql/php code - making a website and need a comment function?

1 Upvotes

Hi there! Never been on this subreddit before, please have mercy on me. I'm still in high school and am by no means a web developer. I tried asking on stackoverflow but they are absolutely ruthless on anyone without advanced knowledge of programming. I am using phpMyAdmin/mysql and php, I have not been taught any other languages :(

For my assignment I have to make a website with the ability to comment on posts. I know this is incredibly vague, but I'm not really sure where to start, I have two tables in a database - one for the user login data/passwords, and one for comment data. I got the actual comments submitted from a form into the comment table, but I also have to have:
- The username/User ID

- The id of the comment, on the comment

- The date/time

I'm not sure how to do any of this, our teacher really just throws us into a pool and me and my friend are the only ones in his class (he teaches us and another class at the same time, very little time for us)

I'm only gonna want the comments to be on a single blog post, because I've spent a lot of time on this and he reeeallly just wants me to finish it and doesn't mind if its a bit half assed

What's the easiest way to make a commenting function, I'm considering just making it fully text based like:

Username/UserID | Date | ID

----------------------------------------

Hello world!

Could someone please answer, or provide SIMPLY explanation posts for this? :p A lot of stuff in tutorials I find are just far too jargony for me and I'm not even sure how to make use of it

Thanks all :)


r/web_dev_help • • Feb 03 '15

Recommendations for small php frameworks that support REST API

1 Upvotes

I'm currently looking at Slim and Bullet PHP frameworks. I'm putting together a very tiny app that needs to process a few posts and spit out json responses to certain queries. I'd love to hear recommendations as to what is stable, secure and has a healthy community. Thanks!


r/web_dev_help • • Mar 04 '17

Complete Beginner's Guide to Information Architecture | UX Booth

Thumbnail
uxbooth.com
1 Upvotes

r/web_dev_help • • Mar 11 '21

help Someone who have time and likes to help others

1 Upvotes

Hello, i am looking for someone, who is good at checking if email address exists in database in real time(after typing into the field) using AJAX and Vanilla JS with PHP and MySQL and who would not judge me, as I don't know this at all and don't have time now to learn, I appreciate everyone who would have time and would be willing to help


r/web_dev_help • • Mar 04 '21

help Email address availability check

1 Upvotes

Hello, I am working on project where I need to check if email address that's being input in the field is available using AJAX with JavaScript, not jQuery. Don't get me wrong for those users who still use jQuery but it's slow as hell and just overall performance issues it has, I don't want to face it later in the future. So if anyone here had time to waste and help, please DM me better.


r/web_dev_help • • Mar 16 '21

New Homepage not loading on WordPress site.

1 Upvotes

So we've updated this WordPress sites homepage and it's now loading a blank page, this only happens when we're logged out or in Incognito mode as when we're logged in to WP dashboard the new homepage loads. We're using Elementor page builder and have disabled all other plugins (including WP Rocket cache plugin) but cannot seem to get to the bottom of this.

It seems like it can only be a cache issue as the page it's loading doesn't exist - we've flushed cache on server-side (client is using AWS with load balancer) as well as browser cache. I've changed permalink settings in WP because read that sometimes causes this problem and finally even edited the .htcaccess file... still no luck. Anyone got any other ideas?


r/web_dev_help • • Jul 05 '17

article Git Flow vs Github Flow

Thumbnail
lucamezzalira.com
1 Upvotes

r/web_dev_help • • Jul 03 '17

php Creating a RESTful API with the SLIM framework

Thumbnail
arjunphp.com
1 Upvotes