MODX - quip display extended field - photo using phpthumbof - modx

Quip
phpthumbof
I have Quip running on my site and I am using a snippet to call a extended profile field from the author of the comment to display the user profile image.
SNIPPET
<?php
if (!empty($userid)) {
$user = $modx->getObject('modUserProfile', array('id' => $userid) );
$extendedfields = $user->get('extended');
$output = $extendedfields[$field];
}
if (isset($output)) { return $output;}
return $default;
In my Quip.comment TPL
<div class="quip-comment-right">
<img src="[[!quip_profile_image? &userid=`[[+author]]` &field=`nomination_file` &default=`text`]]" />
</div>
The above works perfectly and I can see the image, but I cant figure out how to add PHPthumbof, to change size etc....

$output = $modx->runSnippet('phpthumbof',array(
'input' => $output,
'options' => '&w=640&h=480&zc=0&aoe=0&far=0'
));

Related

How to render string html

I have custom block which has following code.
foreach ($video_result as $video){
$title = $video->title;
$video_body = $video->body_value;
}
var_dump($video_body);
$renderable = [
'#theme' => 'video-block',
'#title' => $title,
'#description' => $video_body
];
return $renderable;
And this return to twig file such as
<h6>Title {{ title }}</h6>
{{ description | raw}}
I get output as html on browser and when i inspect it i see html is wrap with double quotes. I have to render it as video on browser. What i am doing wrong here
Try Something Like This
{!! $description !!}

How to display attached images on single.php file in wordpress

Maybe someone solved this problem sorry if I am asking again this question. I have one post displaying on front page now this post has one feature Image along with other images and gallery.
What I want when user click on post so it will go on single.php to show full post view. I want to display on this single.php view an image and some text as well as a custom gallery images but not the feature image.
how can I achieve this I wrote one code but it did not work.
function displayPostImages() {
global $post; function
$attachments = get_children(array('post_parent' => $post->ID, 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'attachment', 'post_mime_type' => 'image' ));
$image = get_post_thumbnail_id( $post->ID); // featured_image ID
$featured_image = wp_get_attachment_image_src($image);
if ($attachments) { // if there are images attached to posting, start the flexslider markup
foreach ( $attachments as $attachment_id => $attachment ) {
if($attachment->ID != $image && $featured_image ){
$img_source = wp_get_attachment_image_src( $attachment_id, 'full' )[0];
//print_r($img_source);
?>
// here will be HTML to display TOP images text and gallery images.
<?php
}
}
}
}
displayPostImages();
?>
and what is returned your function?
I don`t see "return" or "echo $someresult";
empty or not this array $attachments = get_children....

Fuelphp - Using pagination for displaying pages

I'm working on a project with Fuel. I created a pagination , first page has data truly in it but when I click on other pages , url changes but page never refresh and it doesn't show other pages.
codes:
code in Controller :
$config = array(
'pagination_url' => 'http://localhost/body-app/public/app/list/',
'total_items' => 12,
'per_page' => 3,
'uri_segment' => 5,
// or if you prefer pagination by query string
//'uri_segment' => 'page',
);
$pagination = Pagination::forge('mypagination', $config);
$data['example_data'] = DB::select('*')
->from('bodies')
->limit($pagination->per_page)
->offset($pagination->offset)
->execute()
->as_array();
$data['pagination'] = $pagination;
$view=View::forge('app/list',$data);
and my foreach in View is something like this :
<?php foreach($example_data as $per) {
echo $per['name'] ;
} ?>
and finally code to show pagination :
<?php echo Pagination::instance('mypagination')->render(); ?>
If you work with segment number, you should change the route.php file, and add the example 'prod/page/(:page)?' => 'prod' , or add in the you controller one segment string example 'uri_segment' => 'examplenumberpage'.

Image Metadata: altText , height in Orchard CMS

For many of Custom Types created, we have a Query for them. These queries are being used by Projection Widgets (Within Zones).
Few of the custom types have Media Picker field.The Layout type I used for my Queries is the Shape type as seen below:
=>>> Queries:
=>>> Layout:
. I have followed the steps from here.. I specified the name of the shape as : UpcomingHighlightsImages as seen below:
and then included the view: UpcomingHighlightsImages.cshtml in my Themes/MyFirstTheme/Views folder.
Everything works fine upto here.
In the View, problem is that there is NO way to read the Image Metadata such as altText, altHeight etc... Neither there seems to be a way to set these metadata firstly in Orchard itself.
#using Orchard.ContentManagement
#using Orchard.Core.Title.Models
#using Orchard.Fields.Fields
#using Orchard.Taxonomies.Fields
#using Orchard.Core.Common.Fields;
#using Orchard.MediaLibrary.Fields;
#{
var HighlightItems = ((IEnumerable<ContentItem>)Model.ContentItems).ToList();
}
#foreach (var item in HighlightItems)
{
String LinkUrl = ((TextField)item.Parts.SelectMany(x => x.Fields).Single(x => x.Name == "LinkURL")).Value;
String ImagePath = ((MediaLibraryPickerField)item.Parts.SelectMany(x => x.Fields).Single(x => x.Name == "MainImage")).MediaParts.First().MediaUrl;
<div>
<a target="_blank" href="#LinkUrl">
<img src="#ImagePath" />
</a>
</div>
}
So, as seen in above code and the tag, I need:
Set the altText, altHeight property of Image in ORchard CMS
Read these in my view , the way I read LinkUrl and ImagePath
Please guide me !
See how you got the first media part in that ImagePath expression? Well, then you can take that part and get Title, Caption, AlternateText, etc. from it. You can also As<ImagePart>() it and get its Width and Height.

drupal 6 -----why theme() can't output

the code i put in the mytheme template.php
function mytheme_theme(){
return array(
'mytheme_example' => 'example',
'argument' => array('myvar' => null),
);
}
the code i put in the node.tpl.php
<?php
$html = "";
$myvar = "hello,world";
$html .= theme('mytheme_example', myvar);
return $html;
?>
the code i put into the example.tpl.php
<div>
here is the <b><?php print myvar; ?></b>being created.
</div>
i have cleared the cache,but on the node article's page, there is no any output about hello world.
ps:which files i can use the hook_theme, template.php, module file. are there any files i can use this hook?
It looks like you have declared your hook_theme correctly in template.php so I do not think this is the issue.
I did spot a syntax issue with your node.tpl.php, should it not be:
<?php
$vars = array('myvar' => 'hello, world');
$html = theme('mytheme_example', $vars);
return $html;
?>
Note the associate array, with the 'myvar' (the variable declared in hook_theme), is being passed in as the key.
Another point, it is standard practice to name the template file the same as the hook name, so I would suggest calling the template mytheme-example.tpl.php.
See drupal.org for more information
I don't know if you have solved that issue yet.
I would try to declare my theme this way:
function mytheme_theme(){
return array(
'mytheme_example' => array(
'arguments' => array('arguments'=>array()),
'template' => 'example',
),
}
That's how I usually do and it works fine on me.

Resources