I have some project written by someone else using AngularJS and i have to do small changes in it.
There are forms, where user can insert their own text, and it is then displayed on page.
But as far, as i can see, it's not save.
For example, here is fragment of TPL displaying images:
<img src="{$category->iconUrl}" alt="{$category->name}" title="{$category->name}">
Everything works fine, until user will input quote mark in category name.
is there any way to add something like php "addslashes"? in easy way?
So far we've spend with 3 coworkers 6 hours each on so simple task and we all already hate AngularJS :) But work must be done.
It lookes like the category name is inserted in PHP rather than by AngularJS.
If it is Smarty, then the correct syntax would be:
<img src="{$category->iconUrl}" alt="{$category->name}"
title="{$category->name|escape}">
Related
I have a twofold type question regarding Anima's export to code feature in Sketch.
As a designer it's tempting to think of your work straight to code but, the reality is it doesn't quite work like that.
So, the first part of my question is: how good/reliable you think that code is?
The second part is an ask for help with the code.
So, I've created this super simple 2-page random quote generator in Sketch to call out bullshit on the President of Brazil (the crap the guy says...). I designed 3 breakpoints and all that but now that the code is here, I don't know how to do simple things like adding links to the buttons.
Plus, when you click the big green button on the homepage you should be taken to the results.html where a .js is going to generate a sentence.
The .js is ready to go.
Here's the prototype link: https://winter-glade-8944.animaapp.io
Anima is already in its first age , the big problem that most of time , it will be stuck in one page , and you can't get the code of other pages ,
the best solution is to duplicate your project on Figma , then extract the first page's code , then delete this page from anime , then generate the code for the second page ,, and so on
Issue with JSON LD CODE
To start with I am trying to use this code in weebly, buy using embed code option and then I click on the edit custom HTML and enter this code. However, after entering this nothing shows up as in the recipe is not shown on the page and a blank page is shown.
this code is picked on schema.org, for recipes.
Could anyone please help me out in what exactly went wrong. I really appreciate your assistance. FYI- I am new to this. I am trying to set up my own food website and and wanted to schema to for SEO improvement. Any other suggestions are welcome. Thanks in advance.
Please refer this link for the JSON-LD CODE. IT WILL BE AT THE END OF THE PAGE. https://schema.org/Recipe
When you add a JSON-LD block in the HTML, it doesn’t change anything visibly on the page. The script element is hidden by default in all browsers, and you typically want to keep it like that (users typically have no interest in your JSON-LD code).
To check if adding the JSON-LD worked correctly, open the page in a browser and check the source code of the page. You should see the script element with your JSON-LD.
You have to add the content (that should be visible to your users) regularly with HTML. The JSON-LD exists next to your content (duplicating the data like name, photo URL etc.), it doesn’t replace your content.
Bit of a crazy one, certainly a very very frustrating one!
I have a pretty basic ng-repeat going on and it's working in 95% of the cases. However a few of the binds just aren't displaying.
Basic use:
<p>{{result.thingy}}</p>
Nothing shows up in the HTML
However if I use
<p>{{result.thingy | json}}</p>
Then it displays, but with quotemarks around it.
So the data is there, how come it won't show? Is it somehow an invalid type?
I have ported this across from another Angular app which displays it fine, so I suppose there might be a difference in the Angular version or something like that, but this seems crazy to me.
It also shows if I use | number
Apologies, I can't share the data apart from that when I print the full JSON to the screen, it looks like:
"thingy": { "pounds": "174", "pence": "08" }
I was watching some videos on Egghead.io about AngularJS. The creator of the videos uses Webstorm (and, I believe, works for them). One feature I noticed is that he can set different syntax highlighting within different scopes or quotation marks. So, in code like the following (from an AngularJS directive)
return {
template: '<div>something</div>',
// ^^^ these guys ^^^
}
...he can get the inside of the quotation marks to highlight as HTML.
I use Sublime Text 2, and am fairly wedded to it. Is there an existing feature/plugin for Sublime that could handle a case like this? If not, is something like this technically possible using the Sublime Text 2 API?
I don't think it's built in, but it's certainly possible. I've been doing some work with graphviz and wanted to do something similar. Labels can be generated with html like syntax. Anyways, I played around with the .tmLanguage file and added a new pattern to match the context where html like entries were valid (I look for label = <). The patterns I used for the captures aren't that good, but it works for fine for me. This give me the following, which I think is similar to what you are looking for.
I don't know anything about AngularJS, so I can't help you with anything specific to that, but it is certainly possible. Note that in the image below, the last <table></table> are just to show that highlighting doesn't occur there.
Edit:
Forgot to include this in the original post, but here is my updated tmLangauage file. That first pattern is what I added(link). I used PlistJsonConverter to go from JSON to plist, then saved the file as .tmLanguage. Hope this helps.
#skuroda is right, I implemented #skuroda's code with an additional plugin to easily edit HTML within an AngularJS directive JS file. The result is HTML syntax highlighting within a directive JS file and additional functionality to remove string related delimiters while editing templates.... Sublime AngularJS HTML Template Plugin
First time poster here, I'm a designer not skilled at all with php and I have a small issue I don't seem to be able to solve. I'm making a site in drupal 7 using a sub theme on zen.
Btw this is a great CMS, even though people say it's really more a developers CMS. I have no trouble to do what I need using views, rules, display suite etc. So a big thank you for all the developers out there making this such a good CMS. But for this apparently simple problem... no module will help me (I think) and I'm kinda stuck.
So here it is: I'd like to add a subtitle next to the title in all my pages.
So what I did was to add a custom field into the content type basic page (machine name: field_sub_title) which is a simple text field.
I uncommented the following line in my template.php
function mytheme_preprocess_page(&$variables, $hook) {
$variables['sub_title'] = t('field_sub_title');
}
Now my question is how do I load the content of my custom field into that variable?
I know i need to change the second part, but I don't have a clue as into what I need to change this.
Displaying the variable into the the page.tpl.php is something I know about so I only need help with the first part.
{EDIT}
Ok I found how to do this :)
I was looking for a solution in the wrong place. I don't need to change any thing in the template.php file.
Just needed to add this bit of code into my page.tpl.php:
<?php
print $node->field_sub_title['und'][0]['value'];
?>
So I'm posting this here for other Drupal newbies struggling with this....
Your solution may work for now, but there may be a more Drupal-y way to handle a problem like this. If you haven't noticed any problems yet, you may find one or more of the following issues down the road:
Someone who doesn't know php or Drupal theming may need to change the way this works.
If you're like me, you may forget where exactly in code this was implemented.
You may see superfluous markup and/or errors on nodes (content) that do not have this sub-title field (ie. event content not having a sub-title field while basic pages and news articles do).
When you add a field to a content type, it will automatically appear anytime content in that content type is displayed. You should be able to add the sub-title field for your page, event or whatever else you need and have it automatically appear in the markup.
You can 'manage display' of a content type to drag and drop the order for fields to appear. You could take it a step further by using a module like Display Suite to add formatting or layout per-content type.
If you feel like this isn't good enough and the markup for the subtitle must be at the same level as the page title (which is rare), at least add an if statement to make your code check to see if the variable is present before trying to print it. I'd also add a new variable and comments for code readability.
<?php
$subtitle = $node->field_sub_title['und'][0]['value'];
if($subtitle){
print $subtitle;
}
?>
Consider using field_get_items or field_view_value, or at least use the LANGUAGE_NONE constant instead of 'und'
See https://api.drupal.org/api/drupal/modules%21field%21field.module/function/field_get_items/7 and https://api.drupal.org/api/drupal/modules!field!field.module/function/field_view_value/7
This has the added benefit of reducing the number of potential security holes you create.